Skip to content
Latchkey

go install: Usage, Options & Common CI Errors

Build and install a Go binary to your bin directory.

go install compiles a main package and installs the executable into GOBIN (or $GOPATH/bin, default ~/go/bin). With a package@version argument it installs a tool without touching your go.mod.

What it does

Builds the named main package and places the binary in the install directory. The pkg@version form (Go 1.16+) installs in module-aware mode independent of the current module.

Common usage

Terminal
go install ./cmd/app                          # install from this module
go install golang.org/x/tools/cmd/stringer@latest
go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.59.1

Common CI error: installed tool not on PATH

go install puts the binary in ~/go/bin but a later CI step reports "command not found" because that directory is not on PATH. Fix on GitHub Actions: echo "$(go env GOPATH)/bin" >> "$GITHUB_PATH". If you omit @version outside a module you get "go install: version is required" - add it.

Options

FormEffect
./cmd/xInstall from the current module
pkg@latestInstall a tool at latest
pkg@v1.2.3Install a pinned tool version
GOBIN envOverride the install directory

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →