When a tool is registered in go.mod with go get -tool, ensure that the go requirement is at least 1.24.0. If that isn't the case, suggest to the user to upgrade (go mod edit -go=1.24.0).

Rationale

go1.23 can't parse go.mod with a tool directive.

Go version

go version go1.24.5 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''

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:

$ 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)

Comment From: gabyhelp

Related Issues

Related Documentation

(Emoji vote if this was helpful or unhelpful; more detailed feedback welcome in this discussion.)

Comment From: dolmen

Also: go mod tidy applied to a go.mod with a tool directive and the go directive below 1.24 should upgrade the go version.

Maybe @golang/command-line would prefer to force an upgrade of the go version once get -tool is used?