When a tool is registered in go.mod with go get -tool, ensure that the toolchain requirement is at least 1.24.0 (either via the go directive or via toolchain). If that isn't the case, suggest to the user to upgrade (go mod edit -go=1.24.0).
Rationale
go1.23 (and lower) can't parse go.mod with a tool directive, so they can't be used as toolchain.
Go version
go version go1.24.5 darwin/arm64
Output of go env in your module/workspace:
What did you do?
$ cat go.mod
module github.com/dolmen-go/goeval
go 1.23.0
require (
golang.org/x/mod v0.24.0
golang.org/x/tools v0.31.0
)
require golang.org/x/sync v0.12.0 // indirect
tool github.com/dolmen-go/goeval
What did you see happen?
go1.23.11 fails to parse a go.mod that contains a tool directive without a toolchain directive:
$ go1.23.11 list
go: errors parsing go.mod:
go.mod:12: unknown directive: tool
$ go1.23.11 build
go: errors parsing go.mod:
go.mod:12: unknown directive: tool
https://github.com/dolmen-go/goeval/actions/runs/16493582443/job/46633886516#step:4:7
What did you expect to see?
Either:
- go 1.23 to ignore the tool directive
- or go 1.24+
go get -tool fails to add the tool and suggests to increase the minimum go version in go.mod (go mod edit -go=1.24.0)
Edit
This issue was initially about the go directive in go.mod, but is now corrected to be about toolchain.
When a tool is registered in go.mod with
go get -tool, ensure that thetoolchainrequirement is at least1.24.0(either via thegodirective or viatoolchain). If that isn't the case, suggest to the user to upgrade (go mod edit -go=1.24.0).Rationale
go1.23 (and lower) can't parse go.mod with a tool directive, so they can't be used as toolchain.
Go version
go version go1.24.5 darwin/arm64
Output of
go envin your module/workspace:GO111MODULE=''What did you do?
What did you see happen?
go1.23.11 fails to parse a
go.modthat contains atooldirective without atoolchaindirective:https://github.com/dolmen-go/goeval/actions/runs/16493582443/job/46633886516#step:4:7
What did you expect to see?
Either:
go get -toolfails to add the tool and suggests to increase the minimum go version in go.mod (go mod edit -go=1.24.0)Edit
This issue was initially about the
godirective ingo.mod, but is now corrected to be abouttoolchain.