Skip to content
← All Mac folders

Mac folder guide

go-build Cache on Mac: Is It Safe to Delete?

~/Library/Caches/go-build

~/Library/Caches/go-build is Go’s build cache: compiled packages and test results it reuses to make builds faster. It is safe to clear with go clean. The next build is slower while Go fills it again.

Safe to deleteSafe to clear with Go’s own command

What is go-build cache on a Mac?

Go caches the output of every package it compiles. On a Mac the default location is inside ~/Library/Caches, and it can reach several gigabytes.

Downloaded module source lives elsewhere, in ~/go/pkg/mod by default, and has its own clean command.

What’s inside

  • Compiled package outputs
  • Cached test results

How to clear go-build cache safely

  1. Run go env GOCACHE to confirm where your cache is.
  2. Run go clean with the cache flag to clear it.
  3. Add the modcache flag only if you also want to remove downloaded modules.
Check (read only)
go env GOCACHE
Clear the build cache
go clean -cache
Optional: also remove downloaded modules
go clean -modcache

When to keep it

  • The module cache if you work offline, since modules need downloading again

Questions people ask

Is it safe to delete the go-build folder?+

Yes. It is a build cache. Go rebuilds it on the next build.

What is the difference between the build cache and the module cache?+

The build cache holds compiled output. The module cache holds downloaded source. Each has its own go clean flag.

Why is go-build in Library/Caches on a Mac?+

Go uses the operating system’s standard cache folder, which on macOS is ~/Library/Caches.

See which folders fill your Mac

MacZentra, a disk analyzer and storage cleaner for Mac, scans your disk locally and draws it as a Treemap or Sunburst, so a folder like this one shows up with its real size. Scanning and every visualization are free. Cleaning is a one-time $49.99 purchase, and anything you remove goes to the Trash, so it can be restored.

macOS 13 Ventura or later · Apple silicon