skip to content
Alvin Lucillo

Go: Generate

/ 1 min read

💻 Tech

In Go, go:generate is a special comment that can be used to run a command when go generate is run. This is useful for generating code such as GraphQL resolvers.

//go:generate go run github.com/99designs/gqlgen generate

When you run go generate ./..., it will run the command specified in the go:generate comment. In this case, it will run go run github.com/99designs/gqlgen generate.