Skip to content
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: Use toolchain directives for version selection if available, and add tests (v2) #16703

Merged
merged 5 commits into from
Jun 10, 2024

Conversation

mbg
Copy link
Member

@mbg mbg commented Jun 7, 2024

Supercedes #16453 using an implementation based on the new SemVer type introduced by #16460 (which should be merged first).

Context

In Go 1.21, the Go team started making a distinction between language and toolchain versions. Historically, the Go version is declared with a go directive in a go.mod file, or a go.work file. Since Go 1.21, go directives are used to declare the language version. A new toolchain directive may be used to explicitly declare the toolchain version. For backwards compatibility, if there is no toolchain directive, the language version is used as the toolchain version. In the Go autobuilder, we have numerous places where we try to determine the "version" of Go that is in use, should be installed, etc. Here, we are mainly interested in the toolchain version.

What this PR addresses

So far, we have mainly been looking at go directives in go.mod files, and recently go.work files, for this. However, if a toolchain directive is present in either type of file, then this determines the toolchain version. We have not been considering this and this PR addresses that shortcoming by modifying the autobuilder to check for the presence of toolchain directives when determining the version that is in use.

This PR also adds a number of tests for the functions involved in this process.

How to review

Best reviewed commit-by-commit.

@mbg mbg requested a review from a team as a code owner June 7, 2024 11:12
@mbg mbg self-assigned this Jun 7, 2024
@github-actions github-actions bot added the Go label Jun 7, 2024
@mbg mbg force-pushed the mbg/go/improve-version-selection-v2 branch from c65f692 to 040e756 Compare June 7, 2024 11:28
@mbg mbg requested review from a team as code owners June 7, 2024 12:07
@mbg mbg removed request for a team June 7, 2024 12:07
Base automatically changed from mbg/go/semver-type to main June 7, 2024 12:19
@mbg mbg marked this pull request as draft June 7, 2024 12:20
@mbg mbg force-pushed the mbg/go/improve-version-selection-v2 branch from 32d8978 to 881b258 Compare June 7, 2024 12:21
@mbg mbg marked this pull request as ready for review June 7, 2024 12:21
@mbg mbg merged commit 317790e into main Jun 10, 2024
14 checks passed
@mbg mbg deleted the mbg/go/improve-version-selection-v2 branch June 10, 2024 16:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants