Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/go: get does not enforce minimum version from package's go.mod file #48571

Closed
weineran opened this issue Sep 23, 2021 · 1 comment
Closed

Comments

@weineran
Copy link

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

$ go1.15.15 version
go version go1.15.15 darwin/amd64

Does this issue reproduce with the latest release?

N/A

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

go env Output
$ go1.15.15 env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/andrew/Library/Caches/go-build"
GOENV="/Users/andrew/Library/Application Support/go/env"
GOEXE=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/andrew/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/andrew/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/Users/andrew/sdk/go1.15.15"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/Users/andrew/sdk/go1.15.15/pkg/tool/darwin_amd64"
GCCGO="gccgo"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/_w/xf7pz9xj08v6rqptdykvbcnm0000gn/T/go-build196002086=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

GO111MODULE=on go1.15.15 get github.com/zricethezav/gitleaks/v7

What did you expect to see?

The target package (github.com/zricethezav/gitleaks/v7) has a go.mod file that specifies minimum version go 1.16. (https://github.com/zricethezav/gitleaks/blob/master/go.mod)
Therefore, I expect to see a meaningful error like this:

Unable to get package. github.com/zricethezav/gitleaks/v7 requires minimum version [go1.16]. You are running [go1.15.15].

What did you see instead?

...
pkg/mod/github.com/zricethezav/gitleaks/v7@v7.6.1/config/config.go:4:2: package embed is not in GOROOT (/Users/andrew/sdk/go1.15.15/src/embed)

The error message is somewhat misleading. The command actually fails because embed did not exist before go1.16.

Instead, it seems to me the commands should fail immediately because the go version does not satisfy the minimum version specified in the package's go.mod file. It would be great to see something like this:

Unable to get package. github.com/zricethezav/gitleaks/v7 requires minimum version [go1.16]. You are running [go1.15.15].
@seankhliao seankhliao changed the title go get does not enforce minimum version from package's go.mod file cmd/go: get does not enforce minimum version from package's go.mod file Sep 23, 2021
@seankhliao
Copy link
Member

A module needs to declare the higher version to be able to make use of the new features, however, it can still choose to support older versions through the use of build tags.

See also #43980

Closing as I don't think there's anything to do here

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants