Skip to content
Latchkey

go mod download: Usage, Options & Common CI Errors

Pre-download modules into the cache before building.

go mod download fetches the modules named in go.mod (or all of them) into the local module cache without building. Running it early in CI isolates dependency download from compilation and caches well.

What it does

Downloads module zips and metadata into $GOPATH/pkg/mod and verifies them against go.sum. It does not compile anything, so a subsequent go build runs against a warm cache.

Common usage

Terminal
go mod download                   # download all modules in go.mod
go mod download all               # the full module graph
go mod download -x                # print the commands it runs
go mod download -json             # machine-readable output

Common CI error: checksum mismatch

go mod download fails with "verifying ...: checksum mismatch" when go.sum disagrees with what the proxy served (tampering, a force-pushed tag, or a stale sum). Fix: if the change is legitimate, run go mod tidy locally to refresh go.sum and commit it; otherwise investigate the source. For proxy timeouts, set GOPROXY to a reliable mirror.

Options

FlagEffect
allDownload the whole module graph
-xPrint executed commands
-jsonJSON output
GOPROXY envModule proxy to fetch from

Related guides

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