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: go build produces binaries differently when package name has a trailing slash #24456
Comments
Adding a '.' before your path fixes this.
The compiler would have thrown a proper error if you would have done this inside a proper github.com/user/project path. I get this when I try to compile without the '.' for funnel.
|
Thanks @agnivade. Indeed the issue reproduces with a "proper" package path: Works as expected:
Doesn't work with trailing slash:
In my example, the import path was The
but that remains an insufficient workaround. I also noticed the issue can be reproduced with a trailing
but not with
The |
@lrewega in your original report, you said in response to “Does this issue reproduce with the latest release?”:
The “Yes“ and “I cannot reproduce” contradict each other. Is this a regression from older releases? |
@andybons yes I believe it is a regression from older releases. I can only produce it with go1.10. Sorry for being unclear. |
No problem. Thank you for clarifying. |
This appears to be a side-effect of 5993251. |
@0xmohit indeed, it seems to be related to how package-specific flags are provided. In the case where a canonical package name is provided (or has the In the case where a path is provided which appears to be a relative path (such as a trailing It seems you can work around this by using the facilities added in 5993251: use
Note that setting variables in dependency packages produces the same results. Somewhat counterintuitively, setting a variable in a dependency package and specifying a pattern of that dependency package does not work:
but setting the pattern to that of the target command package does work:
I can't tell if this is intentional or not. |
Change https://golang.org/cl/129059 mentions this issue: |
What version of Go are you using (
go version
)?go version go1.10 darwin/amd64
Does this issue reproduce with the latest release?
Yes. I cannot reproduce it with an older release.
What operating system and processor architecture are you using (
go env
)?What did you do?
Notice in the last case, when the package is specified with a trailing slash, the read-only data segment for
main.Subject
is no longer present, and the flags passed to the linker no longer apply.What did you expect to see?
hello universe
What did you see instead?
hello world
I could not reproduce this with go1.9.1 or go1.9.2 -- everything works as expected with older versions.
The text was updated successfully, but these errors were encountered: