Visitar URL original
cmd/go: go get go can write a language version as the toolchain line · Issue #82077 · golang/go · GitHub
Skip to content

cmd/go: go get go can write a language version as the toolchain line #82077

Open

Description

@zlhwdsz

Go version

go version go1.28-devel_3b98eddbcd Wed Oct 7 20:58:28 2026 -0700 darwin/arm64

Output of go env in your module/workspace

GOOS=darwin
GOARCH=arm64
GOTOOLCHAIN=auto
GOVERSION=go1.28-devel_3b98eddbcd Wed Oct 7 20:58:28 2026 -0700

What did you do?

In a module with a go line at a Go 1.21+ language version, and with both the existing toolchain line and target go version below that original go version, run go get go@version.

For example, start with:

module m

go 1.23

toolchain go1.22.9

Then run:

go get go@1.22.9

What did you see happen?

An affected cmd/go can rewrite go.mod to contain an invalid toolchain name derived directly from the original language version:

module m

go 1.22.9

toolchain go1.23

That toolchain line is invalid for Go 1.21 and later, because go1.23 is a language version, not a concrete toolchain version. When the toolchain line is later used, the command reports an error like:

go: invalid toolchain: go1.23 is a language version but not a toolchain version (go1.23.x)

What did you expect to see?

cmd/go should not write an invalid toolchain line.

For Go 1.21 and later, if the original go language version must be preserved as an implied toolchain requirement, it should be canonicalized to the first concrete toolchain version, such as:

toolchain go1.23.0

or the toolchain line should be dropped when it is implied by the final go line.

The relevant issue appears to be that the virtual go module requirement can derive a toolchain name as "go" + version without applying the same Go 1.21+ language-version-to-toolchain-version canonicalization used by toolchain selection.

Activity

  1. added a commit that references this issue on Oct 8, 2026
    de2c610
  2. gopherbot commented on Oct 8, 2026

    @gopherbot
    Contributor

    Change https://go.dev/cl/846845 mentions this issue: cmd/go: canonicalize implied toolchain versions

  3. dmitshur commented on Oct 8, 2026

    @dmitshur
    Member
  4. added
    FixPendingIssues that have a fix which has not yet been reviewed or submitted.
    on Oct 8, 2026
  5. added this to the Go1.28 milestone on Oct 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FixPendingIssues that have a fix which has not yet been reviewed or submitted.GoCommandcmd/go

    Type

    No type

    Projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions