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: "ldflags -X" variable setting does not error on bad paths #30782

larkost-fetch opened this issue Mar 12, 2019 · 3 comments

cmd/go: "ldflags -X" variable setting does not error on bad paths #30782

larkost-fetch opened this issue Mar 12, 2019 · 3 comments


Copy link

@larkost-fetch larkost-fetch commented Mar 12, 2019

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

1.12 or 1.11

Does this issue reproduce with the latest release?

The latest release on Docker, yes, I have not tried master

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

The golang:1.12 docker.

What did you do?

go run -ldflags "-X bad/path/bob.Worked=yes" alpha.go

What did you expect to see?

Some error telling me that I have a bad path.

What did you see instead?

The build succeeded and ran.


The project I work on recently updated the version of Go we are using, and as part of the update some of the variables we are setting using ldflags "-X" stopped getting set because the path we were using was no longer recognized. I know that that mechanism changed, and that is not my objection.

Rather my objection is that the builds continued on without any errors to say we were now trying to set variables on modules that did not exist in the build. There should have been build-breaking errors to prompt us to figure out the problem immediately.


This comment has been minimized.

Copy link

@julieqiu julieqiu commented Mar 12, 2019

@larkost-fetch - would you mind providing some more information about this issue, specifically a code sample and the output that you received after running that command?


This comment has been minimized.

Copy link

@ianlancetaylor ianlancetaylor commented Mar 12, 2019

I couldn't find the issue, but this is an explicit decision, because some build systems pass the same -X options to all programs, but not all programs include the variables being set. The -X option intentionally sets the variable if present and does nothing if absent.


This comment has been minimized.

Copy link

@gopherbot gopherbot commented Apr 12, 2019

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)

@gopherbot gopherbot closed this Apr 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.