Where Is the Go Workspace (GOPATH)?
Go defaults GOPATH to ~/go, holding src, pkg and bin, with module cache and build cache beside it.
Last updated
GOPATH is Go's workspace root, defaulting to a go folder in your home. Source checkouts, compiled packages and installed binaries each get a subdirectory inside.
Modules changed the story but kept the address. The module cache and build cache now do most of the heavy lifting from beside the workspace. GOPATH itself matters less than it used to, yet every Go tool still reads it.
Where Go stores this, by platform
~/go
Default GOPATH with src, pkg and bin inside. Module cache sits in ~/go/pkg/mod and build cache in ~/.cache/go-build. Override with GOPATH env var; confirm with go env GOPATH.
~/go
Same default. Homebrew Go respects it too. Installed tools from go install land in ~/go/bin, so add that to PATH.
%USERPROFILE%\go
Same layout on Windows. Binaries from go install go to go\bin. Check the effective path with go env GOPATH since installers sometimes set it explicitly.
Frequently asked questions
how do i change my gopath
Set the GOPATH environment variable to the new directory. Run go env -w GOPATH=/path for a persistent change. Move src, pkg and bin over to keep existing work.
where does go store downloaded modules
In the module cache at $GOPATH/pkg/mod, read only by design. The build cache beside it at ~/.cache/go-build speeds recompiles. Clear either and Go refetches on demand.
where do go install binaries go
Into $GOPATH/bin, which is ~/go/bin by default. Add it to PATH or every installed tool will seem missing right after installing.
Notice an outdated path? Let us know.