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

go build ignores GoVersion in go.mod file #58420

Closed
jgimenez opened this issue Feb 8, 2023 · 1 comment
Closed

go build ignores GoVersion in go.mod file #58420

jgimenez opened this issue Feb 8, 2023 · 1 comment

Comments

@jgimenez
Copy link

jgimenez commented Feb 8, 2023

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

$ go version
go version go1.19.5 darwin/amd64

Does this issue reproduce with the latest release?

I can not test this, since the bug only happens when you're not using the non-latest version.

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

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/gimix/Library/Caches/go-build"
GOENV="/Users/gimix/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/gimix/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/gimix/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/Cellar/go/1.19.5/libexec"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/Cellar/go/1.19.5/libexec/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.5"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/Users/gimix/tmp/go/go.mod"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/q3/6yf46y5j3cb3wb_sxymhgd980000gn/T/go-build128337086=/tmp/go-build -gno-record-gcc-switches -fno-common"

What did you do?

go.mod file:

module example.com/test

go 1.20

main.go file:

package main

func main() {

}

Then run:

go build

What did you expect to see?

An error like go: go.mod file indicates go 1.20, but maximum version supported by build is 1.19

What did you see instead?

The compilation worked, even if I am using the go 1.19 build tool.

This can lead to code that is syntactially correct in both versions but semantically different, be compiled with the wrong version. For example, if I were using math/rand pacakge, the behavior would be different because of the different seeding method.

@seankhliao
Copy link
Member

working as intended (for now).

see also #57001

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Feb 8, 2023
@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