Check that generated code can be compiled
Opened this issue · 2 comments
brandur commented
I've run into a few instances where Schematic will generated something like this:
// Restart formation.
func (s *Service) FormationRestart(appIdentity int, formationIdentity string) (*Formation, error) {
var formation Formation
return &formation, s.Post(&formation, fmt.Sprintf("/apps/%v/formations/%v/actions/restart", appIdentity, formationIdentity), o)
}
(Which is Go code that cannot compile.)
It can usually be fixed by tweaking some parameters around in a schema, but it might be cool if Schematic performed some kind of sanity check after generating code.
cyberdelia commented
Can you provide the compiler error too?
brandur commented
Oh, definitely! It'll look something like this:
kpi/kpi.go:383: undefined: o
Easiest repro is to set a link's rel
attribute to anything that Schematic doesn't expect, say "restart". An o
for incoming options will get added to the return
line, but will not be defined in the function parameters. These non-standard rel
values are a little unusual, but I don't think they're restricted in any way.