Skip to content

cmd/go: reject to download toolchain when gotoolchain < go directive #72003

Open
@xieyuschen

Description

What version of Go are you using (go version)?

$ go version
go version go1.24.0 darwin/arm64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
AR='ar'
CC='clang'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='clang++'
GCCGO='gccgo'
GO111MODULE=''
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/Users/yuchen.xie/Library/Caches/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/Users/yuchen.xie/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/28/7sypdf0519xfl4ylhq_90s0m0000gp/T/go-build2459204566=/tmp/go-build -gno-record-gcc-switches -fno-common'
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMOD='/dev/null'
GOMODCACHE='/Users/yuchen.xie/go/pkg/mod'
GONOPROXY='git.garena.com'
GONOSUMDB='git.garena.com'
GOOS='darwin'
GOPATH='/Users/yuchen.xie/go'
GOPRIVATE='git.garena.com'
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTELEMETRY='on'
GOTELEMETRYDIR='/Users/yuchen.xie/Library/Application Support/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.24.0'
GOWORK=''
PKG_CONFIG='pkg-config'
uname -v: Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
ProductName:		macOS
ProductVersion:		14.4.1
BuildVersion:		23E224
lldb --version: lldb-1500.0.404.7
Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)

What did you do?

  • Case1:
mkdir verify && cd verify
go mod init m
go mod edit -go=1.26 -toolchain=go1.23.0
go version
  • Case2:
mkdir verify && cd verify
go mod init m
go mod edit -go=1.24 -toolchain=go1.23.0
<my-local-path>/bin/sdk/go1.21.10/bin/go version

What did you expect to see?

Both case 1 and case 2 should be rejected, because go.mod reference said.

The suggested Go toolchain’s version cannot be less than the required Go version declared in the go directive.

Hence, before we actually downloading toolchain, we should check the version inside go.mod and report an error.
For example, go: suggested go toolchain go1.23.0 cannot be less than required go version 1.24

Besides, the case2 looks weird in real usage.

What did you see instead?

  • case1:
go: downloading go1.26.0 (darwin/arm64)
go: download go1.26.0 for darwin/arm64: toolchain not available
  • case 2:
go: downloading go1.24 (darwin/amd64)
go: download go1.24 for darwin/amd64: toolchain not available

Activity

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

    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