SafeDisk AI

Developer storage cleanup

Go Build Cache Taking Too Much Disk Space

If go env GOCACHE points to a cache that has grown into tens or hundreds of gigabytes, treat it as regenerable build cache first. Measure it, make sure no build is running, then clean the Go cache without touching repositories, modules, or local databases.

Free cleanup decision

Get a cleanup decision before you pay.

Leave your email now. The scan summary can follow after the first reply; we offer the $29 Deep Cleanup only if it is useful.

Start SafeDisk Lite scan
Start free scan Send cleanup request

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.

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. Clean build cache first with go clean -cache.
  4. If test artifacts are the issue, also consider go clean -testcache.
  5. Only clean module cache with go clean -modcache if you are willing to re-download dependencies.
  6. Run the build again and watch whether cache growth is one-time or recurring.
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

Do Not Delete First

Deep Cleanup

Still full after the SafeDisk Lite scan?

Start with the SafeDisk Lite scan. If the scan shows review-first storage that still needs judgment, send one request for the $29 Deep Cleanup next step.

Start free scan