-
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: do not modify the 'go.mod' or 'go.sum' files if the 'go' directive indicates a newer-than-supported version? #34262
Comments
I agree that this is generally a good idea, but - will it work well in practice? I've seen a number of issues along the lines of "a command modified my go.mod when I didn't expect it to", or " |
This change would not address most of those issues, because they occur independent of the version in the |
But yes: in general the plan is to remove bugs that introduce unnecessary/erroneous edits to the |
Apologies if I was unclear; I mean that those bugs could be much more annoying with this change in place. For example:
|
If you're on 1.14 and your |
The error I mean is that my version would try to make changes to I'll stop trying to explain this hypothetical scenario if I'm still not making sense :) |
The proposal is to produce an error only for versions of the So the problem you describe could only occur for a Ideally, we we have all of those bugs fixed before |
Change https://golang.org/cl/196519 mentions this issue: |
We should be careful here -- I want to think about this a bit more before moving ahead. We already assume there may be incompatible changes to the go.mod language. If we add a new kind of statement, an old version of the go command will reject it in the main module and ignore it in other modules. The assumption now is that This change makes that stricter: old versions of the go command can't modify a main go.mod file with a greater But I think a few questions need to be resolved:
|
No: it won't do that for the compile step, so it shouldn't do it for loading either.
Rendered moot by withdrawing #34217.
On CL 198319, you suggested that we avoid writing @rsc has also brought up the possibility of adding redundant information to |
I think there are two main issues here:
|
Now that It seems to me that the only remaining possible bad edits are due to explicit uses of |
@jayconrod notes in #34217 (comment):
There is a more general version of this problem: older versions of the Go toolchain may not know how to correctly interpret a
go.mod
file intended for a newer version, and thus could make arbitrarily wrong edits.Probably we should have the
go
command error out instead of making changes if it thinks ago.mod
file generated by a newer toolchain is incomplete or inaccurate.The text was updated successfully, but these errors were encountered: