go command
The single command-line program that ships with Go and builds, runs, tests, formats and documents your code through subcommands.
In more detail
Everything in the Go toolchain is reached as go followed by a verb, such as go build, go test, go vet, go mod or go doc. Every subcommand documents itself: go help build prints its usage line and options. Because the checks ship with the toolchain, a new machine needs nothing else installed.
Example
go help build | sed -n '1,3p'Related terms
- toolchain — A set of programs that work together to get one job done, such as building and running software.
- go build — The go subcommand that compiles a package and its dependencies into an executable file and prints nothing when it succeeds.
- go run — The go subcommand that compiles a program to a temporary place and runs it straight away, leaving no binary behind.
- go test — The go subcommand that builds a test binary from the _test.go files in a package, runs every test function and reports what failed.
- go vet — The go subcommand that looks for code that compiles but is probably wrong, such as a print format verb that does not match its argument.
- go doc — The go subcommand that prints the documentation for a package, function or type from the toolchain you have installed.
Taught in
- What Go Is and Why It Matters — Concurrent Systems Programming with Go
- Installing the Go Toolchain — Concurrent Systems Programming with Go
- Your First Program and go run — Concurrent Systems Programming with Go
- Files and the os Package — Concurrent Systems Programming with Go