Document how to use Go version file as a fallback for Go matrix builds#693
Conversation
This strategy is useful for projects that want to specify a default Go version for their CI builds, while still allowing overrides through the Go matrix to target the latest Go versions.
There was a problem hiding this comment.
Pull request overview
This PR documents the ability to use an empty string for go-version to enable fallback to go-version-file, addressing a commonly misunderstood feature. This is particularly useful for matrix builds where some jobs should use specific Go versions (like stable and oldstable) while others should use the version defined in the project's go.mod file.
- Added empty string syntax documentation to the supported version syntax table
- Added a new section demonstrating matrix testing with go-version-file fallback
- Provides a practical example showing how to combine explicit versions with file-based version specification
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| go-version: ['stable', 'oldstable', ''] # empty string to fall back on go-version-file |
There was a problem hiding this comment.
The comment capitalization is inconsistent with the documentation style. Looking at the "Complete Input Reference" section (lines 365-384), comments are written in sentence case without periods (e.g., "Version or version range of Go to use", "Path to go.mod..."). This comment should be revised to match that style, for example: "Empty string falls back to go-version-file".
| go-version: ['stable', 'oldstable', ''] # empty string to fall back on go-version-file | |
| go-version: ['stable', 'oldstable', ''] # Empty string falls back to go-version-file |
There was a problem hiding this comment.
Why not, I'll wait for a human feedback here
| - uses: actions/setup-go@v6 | ||
| with: | ||
| go-version: ${{ matrix.go-version }} | ||
| go-version-file: "go.mod" # this one is only used when go-version is not specified. |
There was a problem hiding this comment.
The comment capitalization and style is inconsistent with the documentation. Looking at the "Complete Input Reference" section (lines 365-384), comments are written in sentence case without periods and lowercase for field names. This should be revised to match, for example: "Used only when go-version is not specified" or "Fallback when go-version is not specified".
| go-version-file: "go.mod" # this one is only used when go-version is not specified. | |
| go-version-file: "go.mod" # used only when go-version is not specified |
Description:
This strategy is useful for projects that want to specify a default Go version for their CI builds, while still allowing overrides through the Go matrix to target the latest Go versions.
The fact
go-versionsetting can be left empty is often misunderstood.Related issue:
Check list: