setup-go icon indicating copy to clipboard operation
setup-go copied to clipboard

Utilize the .tool-versions file to set expected Go version

Open dsame opened this issue 2 years ago • 5 comments
trafficstars

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.

dsame avatar Jul 27 '23 17:07 dsame

isn't it already implemented in go1.21's go.mod as toolchain option?

troian avatar Aug 10 '23 18:08 troian

the merging is blocked by https://github.com/actions/setup-go/issues/375#issuecomment-1680164710

dsame avatar Aug 16 '23 08:08 dsame

Hello @troian

isn't it already implemented in go1.21's go.mod as toolchain option?

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 avatar Aug 16 '23 08:08 dsame

@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 }}

TastyPi avatar Aug 29 '24 14:08 TastyPi