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.
| Empty string | `''` | No version specified; relies on `go-version-file` when provided |
For more information about semantic versioning, see the [semver documentation](https://semver.org/).
@ -383,6 +384,26 @@ For more information about semantic versioning, see the [semver documentation](h
architecture: 'x64'
```
### Matrix Testing with go-version-file fallback
You can combine go-version with go-version-file in a matrix strategy to test across latest supported Go versions, and the minimal version specified in `go.mod` of your project.
```yaml
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: ['stable', 'oldstable', ''] # empty string to fall back on go-version-file
steps:
- uses: actions/checkout@v6
- 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.
- run: go test ./...
```
## Using setup-go on GHES
setup-go comes pre-installed on GHES when Actions is enabled. For dynamic Go version downloads, the action fetches distributions from the [go-versions repository](https://github.com/actions/go-versions/) on github.com (external to your appliance).