-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
go mod edit: changing go versions in modules to invalid versions updates go.mod and causes weird problems #66491
Comments
Unfortunate, but 1.30 is a valid version number, just not one you can use now, and the forward compatibility go aims for prevents it from modifying newer config it potentially doesn't understand. |
That's valid. Especially when something like However, there's something not nice about being able to set a go version to any float above 1.0, such as |
Also, found a quirk on the `go mod edit` command. Created an issue at golang/go#66491 (comment)
Go version
go version go1.22.0 darwin/arm64
Output of
go env
in your module/workspace:What did you do?
I have a super simple go project (Edit Distance algorithm, ca 100 lines in one main.go) using go.mod with version 1.21. I don't think my code is in any way special or needed for a reproduction.
Anyways, I'm updating my project version 1.22 using
go mod edit
.What did you see happen?
I type
go mod edit -go=1.22
and it looks like everything works.To verify that it actually works, I try
go mod edit -go=1.30
(hoping for an error), and see that go.mod has updated accordingly:Now, I want to go back to version 1.22. I execute
go mod edit -go=1.22
, but get this error message.It now seems to download go version 1.30, exactly when I want to change back to 1.22.
What's worse, is that my go.mod hasn't updated, still at
go 1.30
.No matter what I try, I'm stuck at this version.
Finally, when I now run
go version
, I don't get any output. Rather, it retries downloading the first invalid version, 1.30.Only when I manually change the version in go.mod, does everything go back to normal.
What did you expect to see?
When updating to
go mod edit -go=1.30
. I'd expect the error I got later on when switching back to v 1.22.As a result, I would expect the go version in my
go.mod
file not to change to the invalid go version, rather remaining at its prior version.The text was updated successfully, but these errors were encountered: