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: install -mod=readonly pkg uses -lang=go1.16 #58388

Closed
martin-sucha opened this issue Feb 7, 2023 · 3 comments
Closed

cmd/go: install -mod=readonly pkg uses -lang=go1.16 #58388

martin-sucha opened this issue Feb 7, 2023 · 3 comments

Comments

@martin-sucha
Copy link
Contributor

martin-sucha commented Feb 7, 2023

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

$ go version
go version go1.20 linux/amd64

Also:

$ go version
go version devel go1.21-02d8ebda83 Mon Feb 6 22:13:07 2023 +0000 linux/amd64

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
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/home/martin/.cache/go-build"
GOENV="/home/martin/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/home/martin/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/home/martin/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.20"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/tmp/test/go.mod"
GOWORK=""
CGO_CFLAGS="-O2 -g"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-O2 -g"
CGO_FFLAGS="-O2 -g"
CGO_LDFLAGS="-O2 -g"
PKG_CONFIG="pkg-config"

What did you do?

  1. cd /tmp && git clone https://gist.github.com/c4d5092d60ba6f8328cdf93a48d9c89a.git && cd c4d5092d60ba6f8328cdf93a48d9c89a
  2. go install -p 1 github.com/golangci/golangci-lint/cmd/golangci-lint

What did you expect to see?

No error. Binary gets built and installed into GOBIN. The version used is taken from the go.mod file.

What did you see instead?

# golang.org/x/sys/unix
/home/martin/go/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall.go:83:16: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_linux.go:2255:9: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/sys@v0.1.0/unix/syscall_unix.go:118:7: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/sys@v0.1.0/unix/sysvshm_unix.go:33:7: unsafe.Slice requires go1.17 or later (-lang was set to go1.16; check go.mod)
# golang.org/x/exp/constraints
/home/martin/go/pkg/mod/golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e/constraints/constraints.go:13:2: embedding interface element ~int | ~int8 | ~int16 | ~int32 | ~int64 requires go1.18 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e/constraints/constraints.go:20:2: embedding interface element ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr requires go1.18 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e/constraints/constraints.go:27:2: embedding interface element Signed | Unsigned requires go1.18 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e/constraints/constraints.go:34:2: embedding interface element ~float32 | ~float64 requires go1.18 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e/constraints/constraints.go:41:2: embedding interface element ~complex64 | ~complex128 requires go1.18 or later (-lang was set to go1.16; check go.mod)
/home/martin/go/pkg/mod/golang.org/x/exp@v0.0.0-20220722155223-a9213eeb770e/constraints/constraints.go:49:2: embedding interface element Integer | Float | ~string requires go1.18 or later (-lang was set to go1.16; check go.mod)
# github.com/golangci/gofmt/gofmt
/home/martin/go/pkg/mod/github.com/golangci/gofmt@v0.0.0-20220901101216-f2edd75033f2/gofmt/gofmt.go:195:49: predeclared any requires go1.18 or later (-lang was set to go1.16; check go.mod)

  • Note that when using -mod=mod flag, there is no error and the go.mod and go.sum files are not modified.
  • If I specify the version after the package name in the go install command (go install -mod=mod -p 1 github.com/golangci/golangci-lint/cmd/golangci-lint@v1.50.1), there is no error either. However, I'd like to have the sums of the dependencies committed in my repository in case some of the tags are updated.

I don't know if this is somehow related to #54908 or not.

@martin-sucha
Copy link
Contributor Author

Same error happens when running go build -o=/tmp/golangci-lint-v1.51.0 github.com/golangci/golangci-lint/cmd/golangci-lint from the directory with the go.mod and go.sum files.

@seankhliao
Copy link
Member

I believe this is working as intended, the go.mod/go.sum file is incomplete for the required build of github.com/golangci/golangci-lint/cmd/golangci-lint, as shown when you add a blank import and run go mod tidy.

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 7, 2023
@martin-sucha
Copy link
Contributor Author

Thank you, that at least hints at how I can fix the build.

The error message says that /home/martin/go/pkg/mod/golang.org/x/sys@v0.1.0 uses Go 1.16, while it has Go 1.17 clearly specified in its go.mod file. The error message is misleading. It is not clear from the error message what I need to change to fix the issue. Perhaps the error message should be something like module %s missing from go.mod/go.sum, run go mod tidy instead of the current cryptic message?

@golang golang locked and limited conversation to collaborators Feb 8, 2024
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