Skip to content

Conversation

@ccoVeille
Copy link

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-version setting can be left empty is often misunderstood.

Related issue:

Check list:

  • Mark if documentation changes are required. ✅ done
  • Mark if tests were added or updated to cover the changes.

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.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Suggested change
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

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.
Copy link

Copilot AI Dec 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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".

Suggested change
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

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant