-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Open
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
Description
What version of Go are you using (go version)?
$ go version go version go1.14rc1 darwin/amd64
Does this issue reproduce with the latest release?
This is a regression in Go 1.14rc1. It does not reproduce in 1.13.8.
What operating system and processor architecture are you using (go env)?
go env Output
$ go env GO111MODULE="" GOARCH="amd64" GOBIN="" GOCACHE="/Users/jayconrod/Library/Caches/go-build" GOENV="/Users/jayconrod/Library/Application Support/go/env" GOEXE="" GOFLAGS="" GOHOSTARCH="amd64" GOHOSTOS="darwin" GOINSECURE="" GONOPROXY="" GONOSUMDB="" GOOS="darwin" GOPATH="/Users/jayconrod/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/opt/go/installed" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/opt/go/installed/pkg/tool/darwin_amd64" GCCGO="gccgo" AR="ar" CC="clang" CXX="clang++" CGO_ENABLED="1" GOMOD="/Users/jayconrod/Code/test/tmp2/go.mod" 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/rq/x0692kqj6ml8cvrhcqh5bswc008xj1/T/go-build343063917=/tmp/go-build -gno-record-gcc-switches -fno-common"
What did you do?
Run the testscript below:
go run -ldflags='-X=example.com/test/stamp.STAMP=pass' ./main
stdout pass
-- go.mod --
module example.com/test
go 1.14
-- main/main.go --
package main
import (
"fmt"
"example.com/test/stamp"
)
func main() {
fmt.Printf("STAMP = %s\n", stamp.STAMP)
}
-- stamp/stamp.go --
package stamp
var DEFAULT = "fail"
var STAMP = DEFAULT
What did you expect to see?
The program should print STAMP = pass, and the test should pass.
What did you see instead?
The program prints STAMP = fail.
This only happens when STAMP is assigned to another variable. The test passes if STAMP is assigned the value "fail" instead of DEFAULT.
Other thoughts
I've milestoned this Go1.14 and added the Soon label because this is a regression. It should be triaged before the 1.14 release.
I don't know if this was intended to work before. If not, feel free to close.
If it was intended to work, I'm not sure whether this should block 1.14.
Metadata
Metadata
Assignees
Labels
NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.