Developer storage cleanup
GOCACHE Huge? Fix Go Build Cache Taking Disk Space
If go env GOCACHE has grown into 10GB, 100GB, or even 200GB+ of build artifacts, treat it as regenerable build cache first. Measure it, stop active builds, then clean the Go cache without touching repositories, modules, Docker volumes, or local databases.
Run the free Mac scan before deleting.
The Mac scan reads storage metadata locally, then shows the largest visible buckets and the files that need an AI delete / confirm / protect judgment.
What Is Usually Safe
The Go build cache is normally regenerable. Cleaning it may make the next build slower, but it should not delete your source code. The risky part is confusing build cache with module cache, project directories, Docker volumes, or generated artifacts that you still need.
SafeDisk Lite can flag ~/.cache/go-build as the first cleanup candidate.
The lightweight Mac app scans local metadata, not file contents. When the Go build cache is one of the largest regenerable folders, the free scan can mark it as the one-time optional cleanup candidate and move it to Trash only after you confirm. If larger confirm-first buckets remain, the SafeDisk AI deletion trial is for the exact delete / keep / review order.
# What SafeDisk Lite looks for locally
~/.cache/go-build
~/Library/Developer/Xcode/DerivedData
~/Library/Caches
~/.npm
~/.pnpm-store
~/.docker
~/Downloads
Large Go projects can create cache spikes that look like mysterious System Data.
Recent Go toolchain discussions include real-world GOCACHE reports ranging from a few gigabytes after one test run to well over 100GB on daily-use machines and CI runners. The pattern is familiar: the cache is technically regenerable, but it competes with Xcode, Docker, package caches, and app data for the same disk.
That is why the safe first move is not "delete random folders." It is to separate GOCACHE, GOMODCACHE, Docker storage, Xcode storage, and project output before cleaning anything. SafeDisk Lite looks for ~/.cache/go-build next to those other developer buckets.
# Fast sanity check
go env GOCACHE GOMODCACHE
du -sh "$(go env GOCACHE)" "$(go env GOMODCACHE)" 2>/dev/null
df -h "$(go env GOCACHE)" "$PWD" 2>/dev/null
Measure Go cache without reading code or build output.
These commands show where the cache is and which subfolders are largest. They do not print source files.
go env GOCACHE GOMODCACHE GOPATH
gocache="$(go env GOCACHE)"
du -sh "$gocache" 2>/dev/null
find "$gocache" -maxdepth 2 -type f -print0 2>/dev/null \
| xargs -0 du -h 2>/dev/null | sort -rh | head -30
du -sh "$(go env GOMODCACHE)" 2>/dev/null
df -h "$gocache" "$PWD" 2>/dev/null
Cleanup Order
- Stop active
go test,go build, IDE indexing, and CI jobs on the machine. - Measure
GOCACHEandGOMODCACHEseparately so you know what is cache versus downloaded modules. - If this is CI, isolate cache paths per job or per workspace before cleanup so one workflow cannot silently grow the shared runner cache.
- Clean build cache first with
go clean -cache. - If test artifacts are the issue, also consider
go clean -testcache. - Only clean module cache with
go clean -modcacheif you are willing to re-download dependencies. - Run the build again and watch whether cache growth is one-time, project-specific, or recurring across multiple repos.
Use after active builds are stopped.
This removes Go's build cache and test cache. It does not delete your repositories.
go clean -cache
go clean -testcache
du -sh "$(go env GOCACHE)" 2>/dev/null
df -h "$(go env GOCACHE)" "$PWD" 2>/dev/null
When go clean -cache Is Not Enough
If GOCACHE refills quickly, treat it as a workflow problem instead of a one-time cleanup. Check whether one repository, CI job, or agent session is producing unusually large archives. Space-constrained users may also evaluate compressed cache approaches such as GOCACHEPROG, but those trade disk space for build overhead and compatibility risk. For immediate Mac storage recovery, measure first, clean regenerable cache second, and avoid touching module cache or project output until the biggest bucket is clear.
Go Build Cache FAQ
Can I delete GOCACHE?
Usually yes, after active Go builds and IDE indexing are stopped. It is build cache and Go can regenerate it. The next build may be slower.
Is GOCACHE the same as GOMODCACHE?
No. GOCACHE stores build artifacts. GOMODCACHE stores downloaded module source. Clean build cache first; clean module cache only if you accept re-downloading dependencies.
Why does this show up as Mac System Data?
macOS storage categories often group developer caches, app support folders, local snapshots, and hidden folders under broad labels. Measure the actual folder paths before deleting anything.
Do Not Delete First
- Do not remove your project directory because
go testgenerated a large cache. - Do not delete Docker volumes or database folders just because a Go build failed with ENOSPC.
- Do not run
go clean -modcacheon a slow or offline network unless you accept re-downloading modules. - Do not wipe
$GOPATHblindly; it can contain source checkouts or tools on older setups. - Do not assume macOS System Data is the root cause until you have measured Go, Xcode, Docker, package-manager caches, and Downloads separately.
Still full after the SafeDisk Lite scan?
Start with the SafeDisk Lite scan. If the scan still leaves unclear delete / confirm / protect decisions, send one request for the free SafeDisk AI deletion trial next step.