Developers · Go module cache

Is it safe to delete the Go module cache (~/go/pkg/mod)?

Safe to removeComes back on its own
~/go/pkg/mod

Updated October 17, 2026By the MoreRoom team, Yando Pte. Ltd.This page as Markdown

The short answer

Yes. Rebuilt or re-downloaded automatically when needed.

What is it?

The module cache holds the source code of every Go module version your projects have downloaded, plus toolchains fetched through GOTOOLCHAIN, under ~/go/pkg/mod by default. Go makes these files read-only to protect them, so moving them to the Trash usually fails with permission errors. It typically grows to a few gigabytes.

Downloaded Go modules. Files are read-only, so MoreRoom uses go clean -modcache; modules download again on the next build.

What happens if you delete it?

Modules are downloaded again on the next build, test or go mod download, which takes time and bandwidth. Projects that vendor their dependencies are not affected.

How to remove it properly

Run go clean -modcache in Terminal, Go’s own command, which removes the whole cache permanently despite the read-only files; go env GOMODCACHE shows its location.

Use the tool’s official command: go clean -modcache

How MoreRoom helps

MoreRoom recognises this item, shows its real size and when it was last used, and labels it “Safe to remove”. In the free version you can move it to the Trash in one click, with Undo; Pro collects every safe item at once.

When the tool is installed, MoreRoom runs its official command for you (go clean -modcache) instead of deleting files — and tells you that this step can’t be undone.

Frequently asked questions

Is it safe to delete the Go module cache (~/go/pkg/mod)?

Yes. Rebuilt or re-downloaded automatically when needed. Modules are downloaded again on the next build, test or go mod download, which takes time and bandwidth. Projects that vendor their dependencies are not affected.

Will Go module cache come back after I delete it?

Yes. Modules are downloaded again on the next build, test or go mod download, which takes time and bandwidth. Projects that vendor their dependencies are not affected.

How do I remove Go module cache properly?

Run go clean -modcache in Terminal, Go’s own command, which removes the whole cache permanently despite the read-only files; go env GOMODCACHE shows its location.

Guides that mention it

Related folders