WindowsmacOSLinux

Where Does Go Store Cache and Module Data?

Go GOPATH, module cache and build cache on Windows, macOS and Linux.

Last updated

Go keeps workspaces in GOPATH with pkg mod holding downloaded modules. Build cache sits separately and rebuilds safely.

Env vars GOPATH, GOMODCACHE and GOCACHE override defaults. Moving machines means copying configs plus go.mod files; caches refetch. Check go env for live paths when unsure.

Where Go stores this, by platform

Windows
%USERPROFILE%\go\pkg\mod\

Default module cache (GOPATH %USERPROFILE%\go). Build cache is %LOCALAPPDATA%\go-build. Run go env GOPATH GOMODCACHE GOCACHE to confirm overrides.

macOS
~/go/pkg/mod/

Default GOPATH ~/go. Build cache sits in ~/Library/Caches/go-build. Env overrides win, so check go env before large copies.

Linux
~/go/pkg/mod/

Default GOPATH ~/go. Build cache is ~/.cache/go-build. Caches are disposable; go.mod plus source are the files to back up.

Frequently asked questions

Where is the Go module cache?

At GOMODCACHE shown by go env, by default GOPATH pkg mod. Delete it to force refetch; builds redownload pinned versions from go.mod.

Can I delete the Go build cache?

Yes. GOCACHE only speeds rebuilds. Go recreates it on next build. Keep GOPATH src plus go.mod files; those are the real project state.

Notice an outdated path? Let us know.