Working with the module cache
The module cache is a directory where the Go build system stores downloaded module files. This section describes how to work with the module cache.
How to do it...
The module cache is, by default, under $GOPATH/pkg/mod
, which is $HOME/go/pkg/mod
when GOPATH
is not set:
- By default, the Go build system creates read-only files under the module cache to prevent accidental modifications.
- To verify that the module cache is not modified and reflects the original versions of modules, use this:
go mod verify
- To clean up the module cache, use this:
go clean -modcache
The authoritative source for information about the module cache is the Go Modules Reference (https://go.dev/ref/mod)