You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As the title says, using ConvertTo function with an struct input with a name of Http* is generating the wrong code as it capitalises Http to HTTP. For example:
Define a model as follows:
package design
import (
. "goa.design/goa/v3/dsl" //nolint:revive
"goa_poc/pkg"
)
var HttpConfig = Type("HttpConfig", func() {
ConvertTo(pkg.HttpConfig{})
Attribute("host", String, "The host")
Attribute("port", Int, "The port number")
})
having an external struct like so (assuming this is in a different package/project thus naming cannot be changed):
package pkg
type HttpConfig struct {
Host string
Port int
}
will result in the following convert.go after running generate:
package poc
import (
pkg "goa_poc/pkg"
)
// ConvertToHttpConfig creates an instance of HttpConfig initialized from t.
func (t *HTTPConfig) ConvertToHttpConfig() *pkg.HttpConfig {
v := &pkg.HTTPConfig{}
if t.Host != nil {
v.Host = *t.Host
}
if t.Port != nil {
v.Port = *t.Port
}
return v
}
Whereas the return value is the correct one, the v value is defined with a nonexisting capitalised struct, which does not compile. Service code and generate file are omitted. Full example here: https://github.com/markosfount/goa-poc
The text was updated successfully, but these errors were encountered:
As the title says, using
ConvertTo
function with an struct input with a name ofHttp*
is generating the wrong code as it capitalisesHttp
toHTTP
. For example:Define a model as follows:
having an external struct like so (assuming this is in a different package/project thus naming cannot be changed):
will result in the following
convert.go
after runninggenerate
:Whereas the return value is the correct one, the
v
value is defined with a nonexisting capitalised struct, which does not compile.Service
code and generate file are omitted. Full example here: https://github.com/markosfount/goa-pocThe text was updated successfully, but these errors were encountered: