setup-go
setup-go copied to clipboard
Utilize the .tool-versions file to set expected Go version
Description:
Add '.tool-versions' to 'go.mod' and 'go.work' as a source of the go version
Related issue: link to the related issue.
Check list:
- [ ] Mark if documentation changes are required.
- [ ] Mark if tests were added or updated to cover the changes.
isn't it already implemented in go1.21's go.mod as toolchain option?
the merging is blocked by https://github.com/actions/setup-go/issues/375#issuecomment-1680164710
Hello @troian
isn't it already implemented in go1.21's
go.modastoolchainoption?
i don't think so, because we still have to use the action with the versions prior 1.21 and toolchain option is different in the mean it can call out for different go versions used for build/test/lint tasks. But thank you for pointing out this new feature - it should be incorporated into the action. It would be good to create the feature request .
@dsame is this still planned? It's been nearly a year since the last update.
For everyone like me who found this PR while trying to get actions/setup-go working with .tool-versions, here's the solution we've settled on:
steps:
- uses: actions/checkout@v4
- id: go-version
run: echo "go-version=$(cat .tool-versions | grep golang | cut -d ' ' -f 2)" >> "$GITHUB_OUTPUT"
- uses: actions/setup-go@v5
with:
go-version: ${{ steps.go-version.outputs.go-version }}