What does go do?

the Go toolchain — build, test, and manage Go code.

▸ Explain your own go command →

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

-owrite the output binary to this path
-vprint the names of packages as they compile
-raceenable the data-race detector
-tagsbuild tags to consider satisfied
-ldflagsflags to pass to the linker
-runrun only tests matching this regexp
-countrun each test this many times (use 1 to disable caching)
-coverenable coverage analysis
-benchrun benchmarks matching this regexp

Other commands

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.