-
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
proposal: cmd/go: 'go mod tidy' should remove stale 'replace' directives #30516
Comments
See also #29813. |
In general we don't override grouping. If you wrote three replace lines, they should stay three separate replace lines. (Especially if there are comments involved, but even if not.) I will retitle this to be about unused replaces, which are not as clearly off the table. It's tied up with #29813, though, and in general I'm hesitant to make tidy throw away info that might be needed. |
+1 for removing unused My use case is that we sometimes have to I feel this also makes sense to preserve the expected future behavior. If a dependency is removed and then re-added sometime in the future, it probably should not be overridden by default. The user adding the dependency may not know anything about the context for the older |
Ran into a scenario where I typo'd a path in a replacement directive and spent way too long trying to figure out why my replacement wasn't working. An error or warning for unused replace directives for This replace will silently do nothing:
|
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 created a
go.mod
file with two replaces in separate lines, then rungo mod tidy
.foo3
replacement is unused.What did you expect to see?
A nicely formatted
go.mod
. Moreover, I think the unused replace should be removed.What did you see instead?
The file is unchanged. Also,
go mod edit -fmt
does not format replaces.The text was updated successfully, but these errors were encountered: