Go: Only use EmitInvalidToolchainVersion
if installed toolchain is >=1.21 && <1.23
#18499
+26
−61
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In #15979, we added a diagnostic that warns the user if they are using Go 1.21 or above, their
go.mod
file(s) do not contain an explicittoolchain
directive, and the Go language version does not match the toolchain format. This was a problem, because Go would use the language version as a fallback for the toolchain version and certaingo
commands (notably downloading newer compiler versions) would fail if a language version was used as a toolchain version.However, the Go team have changed their minds about the behaviour if the language version does not match the toolchain version format.
This PR modifies the logic for emitting the diagnostic so that it is only emitted if the installed Go toolchain is in the
>= 1.21 && < 1.23
version range.I did some testing and it seems that even the "problematic" versions in that range now succeed at downloading newer compilers, so we may not need this diagnostic at all, but I opted for leaving it in with the new check since it is technically wrong if one of those versions of the Go toolchain are used.