Skip to content
Latchkey

go get: Usage, Options & Common CI Errors

Add, upgrade, or downgrade a module dependency.

In modern Go (1.16+), go get manages dependencies in go.mod and go.sum. It no longer installs command binaries - that is now go install. Use a @version suffix to pin precisely.

What it does

Resolves a module at the requested version, updates the require directives in go.mod, and records checksums in go.sum. @latest, @v1.2.3, a commit hash, or @none (to remove) all work as version selectors.

Common usage

Terminal
go get example.com/pkg              # add at latest
go get example.com/pkg@v1.4.0       # pin a version
go get -u ./...                     # upgrade deps of the build
go get example.com/pkg@none         # drop a dependency

Common CI error: go get used to install a tool

go get golang.org/x/tools/cmd/stringer fails or warns because go get no longer installs binaries: "go: installing executables with go get ... is deprecated." Fix: use go install golang.org/x/tools/cmd/stringer@latest to install the tool, and reserve go get for adding module dependencies.

Options

FormEffect
pkg@latestLatest tagged version
pkg@v1.2.3Exact version
-uUpgrade to newer minor/patch
pkg@noneRemove the dependency

Related guides

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