Skip to content

cmd/go: "get -tool" should fail if "go" is below 1.24 in go.mod #74739

@dolmen

Description

@dolmen

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    GoCommandcmd/goNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.ToolProposalIssues describing a requested change to a Go tool or command-line program.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions