Skip to content
masterclass Buddy

Go · Command

go generate

go generate runs commands marked by //go:generate directives. It must be invoked explicitly and is commonly used to create or update Go source files.

Last updated

Syntax

go generate [-run regexp] [-n] [-v] [-x] [build flags] [file.go... | packages]

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • go build
  • go test
  • go run
  • go tool
  • gofmt

Source: generate.go — cmd/go/internal/generate — Go source. Checked 2026-11-03.