LinuxmacOSWindows

Where Does Go Store Packages and Binaries?

Go keeps code in ~/go/src, module cache in ~/go/pkg/mod, and binaries in ~/go/bin. GOPATH and GOMODCACHE name them.

Last updated

Go organizes its home folder by role. src holds your code in GOPATH mode, pkg/mod holds the read-only module cache, bin holds installed tools. Two env vars name the roots.

Disk hogs live in the module cache. Old module versions pile up across projects and only a cache clean reclaims them. Source and binaries stay small by comparison.

Where Go stores this, by platform

Linux
~/go (default $GOPATH)

Default workspace: src, pkg/mod cache, bin. Override with GOPATH. Same layout on Mac and Windows under the user profile.

macOS
~/go (default $GOPATH)

Same GOPATH layout. Module cache pruning works identically across OSes.

Windows
%USERPROFILE%\go (default $GOPATH)

Default under the user profile. go env prints the live paths when they were customized.

Frequently asked questions

How do I clear the Go module cache?

Delete ~/go/pkg/mod/cache/download to reclaim space. Builds re-fetch on demand. Never hand-edit inside pkg/mod, it is read-only by design.

My Go paths differ. Why?

Run go env GOPATH GOMODCACHE GOPROXY. Custom env vars move these folders. Check env before scripting backups or cleanups.

Where do go install binaries go?

go install drops binaries into ~/go/bin. Add it to PATH once and installed tools stay reachable across projects.

Notice an outdated path? Let us know.