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

modules: "updates to go.mod needed" when I test 1.20 code using 1.21+ #65751

Closed
AndreasBergmeier6176 opened this issue Feb 16, 2024 · 2 comments

Comments

@AndreasBergmeier6176
Copy link

Go version

go version go1.22.0 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''                                                                                                                                            
GOARCH='amd64'                                                                                                                                            
GOBIN=''                                                                                                                                                  
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/go'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='local'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.22.0'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/app/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'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build405843297=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I have 1.20 code (as expressed in go.mod).
Tried testing inside golang:1.22-alpine Container:

FROM golang:1.22-alpine AS build

ENV CGO_ENABLED=0
WORKDIR /app

COPY go.* ./

RUN --mount=type=cache,target=/root/go/pkg/mod go mod download

COPY . ./

RUN --mount=type=cache,target=/root/.cache/go-build \
    --mount=type=cache,target=/root/go/pkg/mod \
    go build -o /service cmd/*.go

RUN --mount=type=cache,target=/root/.cache/go-build \
    --mount=type=cache,target=/root/go/pkg/mod \
    go test ./... -v

Same happens with golang:1.21-alpine.

What did you see happen?

go build works fine. go test fails with:

go: updates to go.mod needed; to update it:

Aside from the very obscured reason why it needs to be updated - it only happens if I choose 1.21 or 1.22 Golang.
I was under the impression that 1.20 code should build/test with newer versions.

What did you expect to see?

It should build/test using 1.21/1.22 without any change to go.mod.

@seankhliao
Copy link
Member

this is working as intended, starting 1.21 go started enforcing minimum go versions like any other dependency.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 16, 2024
@AndreasBergmeier6176
Copy link
Author

Don't you think it would be better to state that compat. change then in the error message?
Why not then in this case replace go: updates to go.mod needed; to update it: with e.g.:

go: Version in go.mod (1.20) does not match Version of executable (1.21).
Upgrade go.mod to version 1.21.
Exact Go Version matching is enforced from Go 1.21 onward.

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

No branches or pull requests

2 participants