SafeDisk AI

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.

Free Mac scan

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.

Add command output optional

Free trial step. We reply first with a delete / confirm / protect judgment or one read-only detail we still need.

Download free Mac scan See sample result Ask AI about one file
Download free Mac scan Ask free AI 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.

Free scanner behavior

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
Why this suddenly matters

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
Read-only first pass

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

  1. Stop active go test, go build, IDE indexing, and CI jobs on the machine.
  2. Measure GOCACHE and GOMODCACHE separately so you know what is cache versus downloaded modules.
  3. If this is CI, isolate cache paths per job or per workspace before cleanup so one workflow cannot silently grow the shared runner cache.
  4. Clean build cache first with go clean -cache.
  5. If test artifacts are the issue, also consider go clean -testcache.
  6. Only clean module cache with go clean -modcache if you are willing to re-download dependencies.
  7. Run the build again and watch whether cache growth is one-time, project-specific, or recurring across multiple repos.
Regenerable cache cleanup

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

Free AI deletion trial

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.

Download free Mac scan
Add output optional

Start with email. Output can follow after the first reply.