Where Does Go Store Packages?
Go GOPATH, module cache and binary paths on Windows, macOS and Linux, and the go env commands that reveal them.
Last updated
Go keeps workspace sources, the module download cache and installed commands under a GOPATH tree that defaults to go in your home directory. The pkg/mod subfolder holds versioned dependencies, bin holds go install outputs. Since modules arrived, GOPATH no longer needs your own code inside it.
Run go env GOPATH GOMODCACHE GOBIN to print the live values instead of guessing. GOPATH and GOMODCACHE variables move each piece. Clearing pkg/mod is safe and refetches on next build, while wiping bin removes your installed tools.
Where Go stores this, by platform
C:\Users\[Username]\go\pkg\mod
Binaries land in C:\Users\[Username]\go\bin. Set GOPATH or GOBIN to relocate. Keep the bin folder on PATH so installed commands resolve.
~/go/pkg/mod
Same layout as Linux. Homebrew Go installs still default here. Use go clean -modcache to empty the cache safely with nothing else running.
~/go/pkg/mod
Distro Go packages share this default too. GOPROXY and GOSUMDB settings in go env decide where refetches come from after a wipe.
Frequently asked questions
How do I find my Go paths?
Run go env GOPATH GOMODCACHE GOBIN GOPROXY. Those four lines show the workspace root, module cache, binary dir and proxy without opening any config file.
Is it safe to delete pkg/mod?
Yes. The next build redownloads declared versions. Keep go.sum files in your projects so refetches verify against known hashes.
Notice an outdated path? Let us know.