go-generate
run code generation directives in Go source files
TLDR
Run generators in current package
SYNOPSIS
go generate [-run regexp] [-skip regexp] [-n] [-v] [-x] [packages]
DESCRIPTION
go generate scans Go source files for special directives of the form //go:generate command and executes the specified command. It automates code generation before compilation, commonly used for creating string methods, mock implementations, protocol buffers, and other generated code. Directives must start at the beginning of a line with no space between // and go:generate.
PARAMETERS
-run regexp
Run only directives matching regexp.-skip regexp
Skip directives matching regexp.-n
Print commands without executing.-v
Print package names as processed.-x
Print commands as executed.
CAVEATS
Environment variables $GOFILE, $GOLINE, $GOPACKAGE, and $GOROOT are set during execution. Generated files should include a comment matching **^// Code generated .* DO NOT EDIT\.$** before non-comment content.
