cmd/link: -X fails with periods #21206
Closed
Milestone
Comments
What is the output of |
Replace "%2e" with ".", then your problem will be solved. |
$ go tool nm bin/hello | grep Version 4fa4e0 D mypackage%2egit.Version 4b0a48 R mypackage%2egit.Version.str 4fa510 D runtime.buildVersion 516ba8 D runtime.processorVersionInfo |
It seems like replacing %2e with . works but I dont understand why. I can see how it works logically but am not sure if this is expected behavior given the ambiguity. |
This changed in 1.8 because of #16710. The new approach seems better, so I don't see any reason to revert to the old one. This should probably have been in the 1.8 release notes, but I guess we forgot. Closing because I don't think there is anything to do. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
what used to work in go 1.7.3 no longer works in go 1.8
What version of Go are you using (
go version
)?go version go1.8.3 linux/amd64
What operating system and processor architecture are you using (
go env
)?$ go env
GOARCH="amd64"
GOBIN=""
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/home/sig/gopath"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build896116486=/tmp/go-build"
CXX="g++"
CGO_ENABLED="1"
PKG_CONFIG="pkg-config"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
What did you do?
run test_golink.sh (see below for script)
What did you expect to see?
"Version = 1.0.0"
What did you see instead?
"Version = dev"
test_golink.sh script
$ cat test_golink.sh
rm -rf gopath
mkdir gopath
cd gopath
export GOPATH=$HOME/gopath
mkdir -p src/mypackage.git/hello
cat << EOF > src/mypackage.git/config.go
package mypackage
var Version = "dev"
EOF
cat << EOF > src/mypackage.git/hello/main.go
package main
import (
"fmt"
"mypackage.git"
)
func main() {
fmt.Printf("version = %s\n", mypackage.Version)
}
EOF
go clean -i mypackage.git
go install -ldflags "-X mypackage%2egit.Version=1.0.0" mypackage.git mypackage.git/hello
go install mypackage.git/hello
./bin/hello
The text was updated successfully, but these errors were encountered: