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

cmd/go: buld -ldflags -X does not work if a package path ends with "/" #24469

Closed
rockmenjack opened this issue Mar 21, 2018 · 2 comments
Closed

Comments

@rockmenjack
Copy link

rockmenjack commented Mar 21, 2018

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

go version go1.10 linux/amd64

Does this issue reproduce with the latest release?

yes

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

GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOOS="linux"

What did you do?

create a very simple pakcage, try to append version number during compile time

src/dummy/main.go

package main

import "fmt"

var (
	version = "NONE"
)

func main() {
	fmt.Printf("Version is %s\n", version)
}

What did you expect to see?

since below command will run without any error:
go build -o bin/dummy -ldflags "-X main.version=1" dummy/ <- with /
it shall produce the same binary as by:
go build -o bin/dummy -ldflags "-X main.version=1" dummy <- without /

What did you see instead?

The "with /" case, version is not set by -ldflags "-X main.version=1"

@0xmohit
Copy link
Contributor

0xmohit commented Mar 21, 2018

This appears to be the same issue as reported in #24456.

@andybons andybons changed the title go buld -ldflags -X does not work if a package path endswith "/" cmd/go: buld -ldflags -X does not work if a package path ends with "/" Mar 21, 2018
@andybons
Copy link
Member

Duplicate of #24456

@andybons andybons marked this as a duplicate of #24456 Mar 21, 2018
@golang golang locked and limited conversation to collaborators Mar 21, 2019
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

4 participants