LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

go-generate

run code generation directives in Go source files

TLDR

Run generators in current package
$ go generate
copy
Run generators in all packages
$ go generate ./...
copy
Run specific generator by pattern
$ go generate -run [pattern]
copy
Preview commands without executing
$ go generate -n
copy
Run with verbose output
$ go generate -v
copy
Skip generators matching pattern
$ go generate -skip [pattern]
copy

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.

INSTALL

sudo apt install gccgo-go
copy
sudo dnf install gcc-go
copy
sudo pacman -S gcc-go
copy
sudo apk add gcc-go
copy
sudo zypper install gcc-go
copy
brew install go
copy
nix profile install nixpkgs#go
copy

CAVEATS

Environment variables $GOARCH, $GOOS, $GOFILE, $GOLINE, $GOPACKAGE, $GOROOT, $DOLLAR, and $PATH are set during execution. Generated files should include a comment matching **^// Code generated .* DO NOT EDIT\.$ before non-comment content. go generate is never run automatically by go build or go test**; it must be invoked explicitly.

SEE ALSO

go(1), go-build(1)

RESOURCES

Braincup
Open source brain training for math, memory and focus
Braincup mini-games
41 mini-games · Apache-2.0
No ads · No tracking
Play in browser
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid
276 stars
From the maker of Linux Command Library
Copied to clipboard
Braincup
Open source brain training for math, memory and focus. 41 mini-games, from mental arithmetic to Sudoku, N-Back and Solo Chess.
Apache-2.0 licensed · No ads · No tracking · No account
From the maker of Linux Command Library
Download Braincup on the App StoreGet Braincup on Google PlayGet Braincup on F-Droid