-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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 should not accept flags like -modcache with packages #53725
Comments
Doesn't seem to be too uncommon, usually with |
I agree that it's better to report an error since this is confusing and the cost of the mistake can be large, Related #32976, which is marked as duplicate of #28835 even though the motivation of the proposal and the proposed command line structure is different. |
Thanks @seankhliao; the same search also works on github: https://cs.github.com/?scopeName=All+repos&scope=&q=%2Fgo+clean%28+-%5Ba-z%5D%2B%29*%28+-%28cache%7Cmodcache%7Ctestcache%7Cfuzzcache%29%29%2B%28+-%5Ba-z%5D%2B%29*+%5Ba-z%5C.%5D%2B%2F I'm willing to bet that the majority of those lines are buggy. The way they are written, they look like the intent is to e.g. remove the cached test results for a few packages.
Good call out, I did not notice that proposal - cc @bcmills. I think this change could be a stepping stone towards that proposal; any people who currently use |
@bcmills suggests that I should turn this into a proposal, because it's a CLI change that could potentially break some users. See my reasoning above as to why I think the breakage will be minimal, though. |
Reporting an error sounds fine to me. |
This proposal has been added to the active column of the proposals project |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://go.dev/cl/425874 mentions this issue: |
For #53725 Change-Id: I99a85b437d5f918dba74c4eccefcf8087193646a Reviewed-on: https://go-review.googlesource.com/c/go/+/425874 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
After upgrading to Go 1.20, I now see this error: go: clean -testcache cannot be used with package arguments More info: golang/go#53725
I don't think that's a good suggestion. |
@penggy please read the original post carefully - |
@mvdan 😄 |
* remove unnecessary bin target * remove bin directory during clean * fix typo * do not clean entire go build cache (see golang/go#53725) Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
* remove unnecessary bin target * remove bin directory during clean * fix typo * do not clean entire go build cache (see golang/go#53725) Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
* remove unnecessary bin target * remove bin directory during clean * fix typo * do not clean entire go build cache (see golang/go#53725) Signed-off-by: Alexander Yastrebov <alexander.yastrebov@zalando.de>
https://go.dev/cl/425874 was merged in 2022. I think this proposal was implemented in Go 1.20? |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I wanted to simulate fetching a module from proxy.golang.org, and since it is already in my GOMODCACHE, I wanted to delete it from there. So I naively ran:
What did you expect to see?
I expected only a few files/directories to be deleted from GOMODCACHE.
What did you see instead?
It deleted my entire GOMODCACHE; presumably, the command is equivalent to:
Given that flags like
-cache
,-modcache
,-testcache
, and-fuzzcache
clear the entire cache directories in question, they should reject package arguments, because otherwise they are very easy to be misused or misunderstood.It is possible that this might break a few users, but I generally doubt it will be many. I haven't seen any uses of
go clean pkg
in the wild in years. If anyone wants the current behavior ofgo clean -modcache pkg
, they can always dogo clean -modcache; go clean pkg
as shown above, which is also more explicit.The text was updated successfully, but these errors were encountered: