E0418: A service or controller that isn't a struct
app.Service(NewX) registers a service, and @web.Controller (in Go, web.Routes.Controller or app.Controller) a controller: a struct the container constructs, by a constructor — func(deps…) *T or func(deps…) (*T, error) with T a struct — whose parameters are its dependencies. This one builds something else. Reported at boot, and by vukavet.
Wrong
go
type Names []string
func NewNames() Names { return Names{"ada"} }
func main() {
app := web.New()
app.Service(NewNames)
app.Run("")
}Right
go
type Names struct{ list []string }
func NewNames() *Names { return &Names{list: []string{"ada"}} }
func main() {
app := web.New()
app.Service(NewNames)
app.Run("")
}