Everywhere All articles Download Buy — $19

Where apps hide your files

Finding Go's module and build caches

Updated 2026-10-28 · 5 min read

Go stores downloaded modules and compiled build results in two different places, and neither is where most people look first. This page gives both paths, the commands that print them, and the supported way to clear them.

Where they are

~/go/pkg/mod              (downloaded modules: GOMODCACHE)
~/Library/Caches/go-build (build cache: GOCACHE)
~/go                      (GOPATH, the parent of the module cache)

These are the defaults on macOS, and Go will tell you its real values. On the Mac used for this guide, go env reported:

go env GOPATH GOMODCACHE GOCACHE

as ~/go, ~/go/pkg/mod and ~/Library/Caches/go-build. If you have set any of these variables, your output will differ, so run that command first and trust it over this page.

To open a folder in Finder, use Go > Go to Folder (⇧⌘G) or Terminal:

open "$(go env GOMODCACHE)"
open "$(go env GOCACHE)"

A folder only exists once Go has used it. On the Mac used for this guide, ~/go contained only pkg/sumdb and no mod folder yet, and the build cache folder had not been created, because no module had been downloaded or compiled recently. Both appear after the first go build or go get.

What each location holds

LocationWhat it is
GOPATH/pkg/modThe module cache. Downloaded dependencies, unpacked as read-only source trees named like github.com/<owner>/<repo>@<version>.
GOPATH/pkg/mod/cache/downloadThe raw downloads (zips and metadata) the unpacked trees come from. The inner layout is a Go implementation detail.
GOPATH/pkg/sumdbChecksum database records Go uses to verify downloaded modules. Present on this Mac.
GOPATH/binPrograms installed with go install, unless GOBIN points elsewhere.
GOCACHE (~/Library/Caches/go-build)Compiled packages and test results, in hash-named folders. Disposable.

Go's own toolchain is separate again. go env GOROOT shows where the Go installation lives: /usr/local/go for the official installer, or inside the Homebrew Cellar for a brew install (on the Mac used for this guide it was under /usr/local/Homebrew/Cellar/go/, an Intel Homebrew prefix; an Apple silicon Homebrew install would be under /opt/homebrew). With the GOTOOLCHAIN default of auto, a newer Go toolchain that a project asks for is downloaded like any other module (as golang.org/toolchain), so it lands in the module cache too.

Why you cannot just delete the module cache

Go makes module directories read-only on purpose, so a normal Finder delete or rm -r may fail with permission errors. Go provides its own cleaner:

go clean -modcache

The Go documentation says this removes the whole module cache. Modules are downloaded again when a build needs them, so the only cost is time and bandwidth. If you want future cache folders to be deletable with ordinary tools, go env -w GOFLAGS=-modcacherw makes Go create them read-write, as its module documentation describes.

Never run go clean -modcache expecting it to touch your projects; it only affects the cache. But it removes every version, including ones your offline builds may depend on, so run go mod download in a project to refill what it needs.

Cleaning the build cache

go clean -cache
go clean -testcache

-cache removes the entire build cache. -testcache only expires cached test results, which is what you want when a test looks stale. The build cache is disposable: the next build is slower and then fast again. Go also deletes cache entries it has not used recently on its own, so you rarely need either command.

Seeing what takes the space

du -sh "$(go env GOMODCACHE)" "$(go env GOCACHE)" 2>/dev/null

This only reads sizes, and prints nothing for a folder that does not exist.

Moving either cache

Set a different value with go env -w, which stores it in Go's own settings file instead of your shell profile:

go env -w GOMODCACHE=/Volumes/FastDrive/gomod
go env -w GOCACHE=/Volumes/FastDrive/gobuild

Go's settings file lives at the path printed by go env GOENV; on the Mac used for this guide that was ~/Library/Application Support/go/env. It is a plain list of KEY=value lines, but it can hold proxy settings, so look at it privately. A shell export works in Terminal sessions, while go env -w also applies to builds started from an IDE. Move or delete the old folder yourself; Go does not migrate it.

Backing up or moving to a new Mac

Back up your source and your go.mod and go.sum files, not the cache. The cache is rebuilt from go.sum-verified downloads. If a private module is hard to fetch, check go env GOPRIVATE and your credentials set-up before you wipe anything.

Why Spotlight and Finder miss them

Spotlight and Finder searches leave out ~/Library/Caches, so the build cache never shows up. ~/go itself is an ordinary visible folder, but each module sits in a folder named like cobra@v1.8.0 under its host and owner folders, so searching for the import path you see in go.mod matches nothing.

Finding a module by name

Everywhere indexes file names inside caches and package folders, so typing a module's folder name such as net@v0 or a package name like cobra finds the unpacked sources under ~/go/pkg/mod. It searches names, not code, so use it to locate the folder and then open it in your editor. ⌘T opens a Terminal there, which is handy before running go clean.

Common questions

Where does Go store downloaded modules on a Mac?

In ~/go/pkg/mod by default, which is GOPATH/pkg/mod. Run go env GOMODCACHE to see the exact folder your setup uses.

Where is the Go build cache on macOS?

In ~/Library/Caches/go-build. go env GOCACHE prints the actual path.

How do I clear the Go module cache?

Run go clean -modcache. Plain deletion can fail because Go creates module folders read-only.

What is GOPATH on a Mac?

By default it is ~/go. It holds the module cache in pkg/mod and programs installed with go install in bin.

Find any file before you finish typing

Everywhere keeps track of every file on your Mac — including the folders Spotlight hides and drives you have unplugged. Free for a day, then $19 once.

Version 2.20.3 · macOS 13+ · 4.7 MB · notarised

Related

© 2026 Caretopia Network Private Limited Everywhere for Mac Buy a licence Articles Privacy Support