Reputation: 8068
I'm using Go 1.13.1, latest as of today.
I'm trying to completely remove a package that I installed with go get
from GitHub. The go clean -i <PACKAGE_NAME>
didn't seem to work, since there are files spread through, at least, these directories:
~/go/pkg/mod/github.com/<PACKAGE_NAME>
~/go/pkg/mod/cache/download/github.com/<PACKAGE_NAME>
~/go/pkg/mod/cache/download/sumdb/sum.golang.org/lookup/github.com/<PACKAGE_NAME>
Is there a way to clean everything without removing all that manually?
Upvotes: 30
Views: 94435
Reputation: 189
We can remove cache for one or multiple packages from GOPATH
easily.
vcs
folder in GOPATH/pkg/mod/cache
.GOPATH/pkg/mod/cache/download/{Package_name}/{library_name}
or remove files ({version_to_delete}.*) belongs to specific version and update list
file.GOPATH/pkg/mod/{Package_name}/{library_name}@{version}
.go mod tidy
in your project root folder. It should download library from the internet instead of respawing from local cache.Upvotes: 5
Reputation: 418435
This is currently not supported. If you think about it: it may be the current module does not need it anymore, but there may be other (unrelated) modules on your system that may still need it. The module cache is "shared" between all the modules on your system; it can be shared because dependencies are versioned, and if 2 unrelated modules refer to the same version of a module / package, it's the same and can be shared.
The closest is go clean
with -modcache
, but that removes the entire module cache:
The -modcache flag causes clean to remove the entire module download cache, including unpacked source code of versioned dependencies.
Upvotes: 55