go tool: Usage, Options & Common CI Errors
Run the lower-level tools shipped with the Go toolchain.
go tool runs the compiler’s auxiliary programs: pprof for profiling, cover for coverage reports, trace for execution traces, and more. In CI it most often turns a coverage profile into a summary or HTML.
What it does
Dispatches to a named tool installed with the Go toolchain. Running go tool with no argument lists the available tools for your platform.
Common usage
go test -coverprofile=cover.out ./...
go tool cover -func=cover.out # per-function coverage summary
go tool cover -html=cover.out -o coverage.html
go tool pprof cpu.prof # analyze a CPU profileCommon CI error: unknown tool
go tool foo fails with "go: no such tool foo" when the name is wrong or the tool is not bundled (e.g. stringer, which is installed separately). Fix: run go tool to list valid tools; install standalone tools with go install <path>@version and invoke them directly, not via go tool.
Common tools
| Tool | Use |
|---|---|
| cover | Coverage summary / HTML |
| pprof | CPU/memory profiling |
| trace | Execution tracing |
| objdump | Disassemble binaries |