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: automatic toolchain upgrades make the combination of go version
and go install <package>@<version>
confusing
#66518
Comments
|
To me, that would make it even more confusing. Please don't try to fix the opaque toolchain behavior by bolting on even more complexity. |
I would expect I see that your latest go.mod declares 1.22. When that's released users who build To put this another way, I think what makes this the most confusing is that we're crossing the 1.21 toolchain switching version boundary here with a 1.19 module, and a local 1.21 toolchain. This should be less confusing once we're on the other side of that boundary. |
But if we assume that tools support the last two versions of Go, then the latest release of my module will have a The behavior you describe is generally fine for most software written in Go, but not tools that operate on other Go code. |
Hm I think I still need to understand something. Now that 1.21 and 1.22 are the last two versions of Go, can we assume that everyone (that we support) has a version of Go that's capable of switching to a newer toolchain and build the tool using that newest toolchain? Will your tool work with 1.21 code if it's built with 1.22? |
Yes, but not vice versa. Is your point that with automatic tool switching, there is no reason to support older versions of Go, and that go-tools should always specify the latest version of Go in its
I don't want to be forced to depend on a newer version of Go for users to have an easier time |
First of all, I agree that the newly versioned world we live in is confusing, and I don't think we've done enough to mitigate that confusion. For example: the fact that However, with respect to forcing toolchain upgrades:
In other words, I am hopeful that in the future most tools can upgrade their toolchain requirements frequently. This will allow for faster iteration with the standard library, and will make it more likely that fixes or new APIs get upstreamed rather than worked around. In another world, it would have been nice for go/parser, go/types, etc. to live in a separate module, but it's too late for that, and forward compatibility provides a similar outcome. |
Go version
that's a good question!
Output of
go env
in your module/workspace:What did you do?
As the author of Staticcheck, I tell my users that to support Go 1.22 code, they have to build Staticcheck with Go 1.22. To assure me that they did, they show me this:
The problem is that the user's local toolchain is Go 1.21.8, but the module they're currently in is specifying
go 1.22.1
in its go.mod. Runninggo version
downloads and runs the newer toolchain, as doesgo install .
, butgo install honnef.co/[...]
does not.This is problematic in a multitude of ways.
That
go install
behaves this way is documented ingo help install
asThis, however, predates the automatic upgrades. In my experience, users who are aware of automatic upgrades think of it as "First,
go
downloads the specified toolchain, then it runs the subcommand", which is true in most, but not all cases.The issue I am filing is really a mix of two user reports, one from the perspective of a tool maintainer, and one from the perspective of a user. What they have in common is confusion over the effective Go version.
To avoid any confusion I've included a sample shell session demonstrating the current behavior.
The text was updated successfully, but these errors were encountered: