Safe to Delete

Go Language Build & Module Cache (~/.cache/go-build)

Quick Answer: ~/.cache/go-build and $GOPATH/pkg/mod store compiled Go packages and modules. Running go clean -cache is safe and reclaims lost storage space.

Bottom Line: It is 100% safe to clear the Go build and module cache. Running go clean -cache will not delete your Go source code (.go files) or project dependencies.


What is the Go Build Cache Folder?

Located at ~/.cache/go-build on Linux/macOS or %LocalAppData%\go-build on Windows (plus $GOPATH/pkg/mod), this directory is created by the Go (Golang) compiler.

When you compile or test Go programs using go build or go test, Go caches compiled package object files so future builds compile instantly. Additionally, go get caches downloaded dependency modules in $GOPATH/pkg/mod.

Over months of building Go applications, these caches accumulate old package versions, taking up 5 GB to 20 GB+.


Can You Delete the Go Cache?

✅ Yes, it is completely safe to delete.

  • No source code lost: Your .go code files, go.mod, and go.sum files are untouched.
  • Auto-download on demand: Go will re-download modules and re-compile packages on your next go build.

How to Safely Clean Up Go Cache

To purge all compiled Go build artifacts:

go clean -cache

To purge downloaded module dependencies in $GOPATH/pkg/mod:

go clean -modcache

To purge both build cache and module cache in one command:

go clean -cache -modcache -testcache

  • Learn about deleting [Rust Cargo target))))))))))))))))))))))) folder].
  • How to clean up pip cache.
  • Check if you can clean node_modules.

Discussion

Loading authentication...

Related in developer

The AI Engineer's Model Disk Cleanup Guide: Hugging Face, Ollama & PyTorch

The ultimate 1,200-word field guide for AI developers and local LLM hobbyists to reclaim 200GB+ from Ollama, Hugging Face, PyTorch, and vLLM model weights.

Safe to Delete

Android Studio System Index Cache (AndroidStudio Cache)

Android Studio caches Gradle project indexes, VFS caches, and compiler artifacts. Invalidate and clear is safe.

Safe to Delete

Ansible Automation Temp & Fact Cache (~/.ansible/tmp)

Ansible stores temporary playbook execution modules and target host fact JSON caches in ~/.ansible/tmp. Clearing Ansible tmp is safe.

Safe to Delete
Back to all files