-
-
Notifications
You must be signed in to change notification settings - Fork 575
Closed
Description
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
Metadata
Metadata
Assignees
Labels
No labels