WindowsmacOSLinux

Where Does Go Store Modules and Build Cache?

Go GOMODCACHE module cache and GOCACHE build cache on Windows, macOS and Linux via go env.

Last updated

Go keeps downloaded modules in a pkg/mod tree (GOMODCACHE) and build artifacts in a separate build cache (GOCACHE). Both default under your home or Local AppData.

Print them with go env rather than guessing. GOPATH, GOMODCACHE and GOCACHE all move with env vars, so installs disagree.

Where Go stores this, by platform

Windows
%USERPROFILE%\go\pkg\mod

Default GOMODCACHE with stock GOPATH. Build cache defaults under %LOCALAPPDATA%\go-build. Print live values with go env.

macOS
~/go/pkg/mod

Same defaults. Module zips are read only by design; use the mod download command to inspect rather than chmodding.

Linux
~/go/pkg/mod

Same defaults. The clean command with modcache flag wipes downloads safely when disk runs low.

Frequently asked questions

How do I print my Go module cache path?

Run go env for GOMODCACHE, GOPATH and GOCACHE. Those three answer every where is Go keeping X question.

Can I delete the Go build cache?

Yes. The clean command with the cache flag clears builds; modcache clears downloads. Both rebuild on demand.

Notice an outdated path? Let us know.