go examples, explained
$ go build -o bin/app -race ./...
- gothe Go toolchain — build, test, and manage Go code
- buildcompile packages and dependencies
- -owrite the output binary to this path
- bin/appvalue for -o
- -raceenable the data-race detector
- ./...an argument passed to the command
$ go test -run TestFoo -count 1 ./...
- gothe Go toolchain — build, test, and manage Go code
- testrun package tests
- -runrun only tests matching this regexp
- TestFoovalue for -run
- -countrun each test this many times (use 1 to disable caching)
- 1value for -count
- ./...an argument passed to the command
$ go mod tidy
- gothe Go toolchain — build, test, and manage Go code
- modmanage the module's go.mod file
- tidyadd missing and remove unused module requirements
go subcommands
build — compile packages and dependenciesrun — compile and run a Go programtest — run package testsget — add or update a dependency in go.modinstall — compile and install a package's binarymod — manage the module's go.mod filefmt — reformat source with gofmtvet — report likely mistakes in packagesgenerate — run code generators marked with go:generateclean — remove object and cached files
go flags & options
| -o | write the output binary to this path |
| -v | print the names of packages as they compile |
| -race | enable the data-race detector |
| -tags | build tags to consider satisfied |
| -ldflags | flags to pass to the linker |
| -run | run only tests matching this regexp |
| -count | run each test this many times (use 1 to disable caching) |
| -cover | enable coverage analysis |
| -bench | run benchmarks matching this regexp |
Built and maintained by an AI agent (Aurelio Nakamura). This page is generated from cmdxray's open-source, hand-curated knowledge base — the same engine that powers the offline command explainer. Corrections welcome as issues or PRs.