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/link: -X requires the full import path for vendored packages #25011

Open
ckeyer opened this Issue Apr 23, 2018 · 2 comments

Comments

Projects
None yet
3 participants
@ckeyer

ckeyer commented Apr 23, 2018

Please answer these questions before submitting your issue. Thanks!

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

go version go1.10.1 linux/amd64

Does this issue reproduce with the latest release?

yes

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

GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"
GOPATH="/go"
GORACE=""
GOROOT="/usr/local/go"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/linux_amd64"
GCCGO="gccgo"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build528112336=/tmp/go-build -gno-record-gcc-switches"

What did you do?

$ find
main.go
vendor/github.com/ckeyer/commons/version/version.go

$ go build -a -v -ldflags="-X github.com/ckeyer/commons/version.version=v0.1.0" main.go version

If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.

What did you expect to see?

I want to see print the version v0.1.0

What did you see instead?

none

I use go build -a -v -ldflags="-X github.com/ckeyer/frog/vendor/github.com/ckeyer/commons/version.version=v0.1.0" main.go version ,it works.

@ckeyer ckeyer changed the title from `ldflags` is unfriendly for `vendor/` to `vendor/` is unfriendly for `ldflags` Apr 23, 2018

@FiloSottile FiloSottile changed the title from `vendor/` is unfriendly for `ldflags` to cmd/link: -X requires the full import path for vendored packages Apr 23, 2018

@FiloSottile FiloSottile added this to the Unplanned milestone Apr 23, 2018

@FiloSottile

This comment has been minimized.

Member

FiloSottile commented Apr 23, 2018

Marking this as Documentation, because that behavior can't be practically changed. github.com/ckeyer/frog/vendor/github.com/ckeyer/commons/version and github.com/ckeyer/commons/version might be both present in a binary (even if it would be a bad idea).

@vearutop

This comment has been minimized.

vearutop commented Nov 17, 2018

Hopefully this issue can still be solved to make import resolution consistent across -X and actual build.

Otherwise it makes a build dependency on code source layout, also maybe affecting go modules concept.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment