go-tool
Compile, test, and analyze Go code
TLDR
List available tools
Run the go link tool
Print the command that would be executed, but do not execute it (similar to whereis)
View documentation for a specified tool
List all available cross-compilation targets
SYNOPSIS
go tool [-n] [toolname] [tool args ...]
PARAMETERS
-n
Print commands that would be executed without running them
DESCRIPTION
go tool is a gateway command in the Go programming language toolchain on Linux and other Unix-like systems. It provides direct access to low-level build tools bundled with the Go distribution, such as compilers, linkers, disassemblers, and analyzers.
Normally, users rely on high-level go subcommands like go build, go test, or go run, which orchestrate these tools automatically. However, go tool enables manual invocation for advanced scenarios, like custom compilation flags, debugging binaries, or integrating into build scripts.
Without arguments, it lists all available tools (e.g., compile, link, asm, objdump, nm, pprof). Specifying a tool name runs it with passed arguments, mimicking direct executable calls while respecting Go's environment.
This command is essential for toolchain development, reverse engineering Go binaries, or when higher-level commands fall short. It operates within the $GOROOT/pkg/tool directory, where platform-specific binaries reside.
CAVEATS
Primarily for advanced users; misuse can lead to incompatible binaries. Tools are platform-specific and version-locked to the Go release.
COMMON TOOLS
compile: Compiles Go packages.
link: Links object files into executables.
asm: Go assembler.
objdump: Disassembles binaries.
pprof: Profiles CPU/memory.
USAGE NOTE
List tools with go tool; find binaries in $GOROOT/pkg/tool/linux_amd64.
HISTORY
Introduced in Go 1.0 (2012), evolving from pre-release toolchain (6g/8g compilers). Modernized with Go modules in 1.11+; tool list expands per release (e.g., trace in 1.7).
SEE ALSO
go(1)


