fixes toolchain directive getting into go.mod #7884
Merged
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.
Fixes #7868
I had to read https://tip.golang.org/doc/toolchain#select a few times to understand this so let me summarize:
With
GOTOOLCHAIN
unset, Go 1.21 will use the locally installed toolchain (1.21.0 currently) if the go directive is <= 1.21. This means it was injecting the new toolchain directive and updating the go directive to 1.21 in oldergo.mod
s, but Dependabot code reverts the change to the go directive, which is how we ended up with #7868. This only affected go.mod files that had dependencies that were on 1.21.By switching to
GOTOOLCHAIN="go1.20+auto"
we revert to using Go 1.20 to retain the current behavior forgo.mod
with go directive <=1.20, but theauto
means anygo.mod
that are on newer versions will automatically select the right Go toolchain and download it if not installed locally.Thus technically this is the last bump we ever need to do with the Go version. Although to prevent each job from downloading the Go toolchain on-the-fly we can pre-install multiple popular versions.