Skip to content

Should the go directive in go.mod a semver version (including patch), or not? #68971

Closed as not planned
@StefMa

Description

@StefMa

Go version

go version go1.22.2 darwin/arm64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='arm64'
GOBIN=''
GOCACHE='/Users/stefan/Library/Caches/go-build'
GOENV='/Users/stefan/Library/Application Support/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='arm64'
GOHOSTOS='darwin'
GOINSECURE=''
GOMODCACHE='/Users/stefan/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='darwin'
GOPATH='/Users/stefan/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/opt/homebrew/Cellar/go/1.22.2/libexec'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/opt/homebrew/Cellar/go/1.22.2/libexec/pkg/tool/darwin_arm64'
GOVCS=''
GOVERSION='go1.22.2'
GCCGO='gccgo'
AR='ar'
CC='cc'
CXX='c++'
CGO_ENABLED='1'
GOMOD='/dev/null'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -arch arm64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -ffile-prefix-map=/var/folders/m3/xsbbvz1j6sgd2_50b2m88vj80000gn/T/go-build1885746714=/tmp/go-build -gno-record-gcc-switches -fno-common

What did you do?

Given a simple go.mod file:

module github.com/cli/cli/v2

go 1.23

No other files are available.

Then I run go build.

What did you see happen?

When I run go build I get the following error:

go: downloading go1.23 (darwin/arm64)
go: download go1.23 for darwin/arm64: toolchain not available

What did you expect to see?

I don't expect an error.
According to this docs:

A go directive indicates that a module was written assuming the semantics of a given version of Go. The version must be a valid Go version, such as 1.9, 1.14, or 1.21rc1.

Heading over to the Go version link I can find this:

The syntax ‘1.N’ is called a “language version”. It denotes the overall family of Go releases implementing that version of the Go language and standard library.

Because of that, I would expect that I can use a "language version" as go directive.
But it is not working.
So either go behaves wrong (by not accepting a "langauge version" as a go directive), or the docs are not correct and needs to be changed. It seems only a "release name" is supported.
Looking at https://go.dev/doc/devel/release, I guess I can use each and every version mentioned here.
Hence, I can't use 1.21 (and up) anymore, since this release simply doesn't exist anymore.

I'm unsure what is the correct behaviour. Please let me know whats correct and what needs to be adjusted/fixed/changed.
Thanks! 🙃

Furhter reading where this is comming from (and for cress referencing):
cli/cli#9489

Metadata

Metadata

Assignees

No one assigned

    Labels

    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions