Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: `go clean <package>` downloads modules #32977

hyangah opened this issue Jul 8, 2019 · 1 comment


None yet
2 participants
Copy link

commented Jul 8, 2019

#28680 is fixed and go clean --modcache command no longer donwloads modules before cleaning if no argument is given to the command.

Note however 'go clean' accepts packages parameter as an argument(which isn't relevant to -modcache but is still meaningful for other purposes of go clean). If they are given, go clean still downloads the modules and even updates the go.mod file.

$ go help clean
usage: go clean [clean flags] [build flags] [packages]
$ export GOPATH=$(mktemp -d)
$ go1.13beta1 clean -testcache -cache -modcache
$ go1.13beta1 mod init scratch
go: creating new go.mod: module scratch
$ go1.13beta1 clean
go: finding v0.3.2
go: downloading v0.3.2
go: extracting v0.3.2
$ cat go.mod
module scratch

go 1.13

require v0.3.2 // indirect

And the go clean -modcache <package> behaves differently.

$ go1.13beta1 clean -modcache
$ go1.13beta1 clean -modcache
go: downloading v0.3.2
go: extracting v0.3.2
go: finding v0.3.2

@hyangah hyangah added the modules label Jul 8, 2019

@bcmills bcmills added this to the Go1.14 milestone Jul 8, 2019


This comment has been minimized.

Copy link

commented Jul 8, 2019

Probably the best we could do here is to detect that the argument to clean is not in the main module and error out.


If a package argument is given or the -i or -r flag is set, clean removes the following files from each of the source directories corresponding to the import paths: […]

But of course we cannot remove files from the (read-only) module cache.

CC @jayconrod

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.