You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm fine with the idea in principle but I don't see how it is possible in practice. We decided a long time ago that the linker should accept a -X option for an unknown symbol, so that people could use a single set of -X options to build multiple programs. In your test Surname is a constant, so the linker never sees it. The effect is that the linker thinks you are using -X with an unknown symbol, so it doesn't do anything.
I'll leave this open for now in case someone else thinks of a way to implement it.
That's reasonable. I wondered whether this was a result of the const disappearing before the -X was considered, but I'm not familiar with the full steps involved. Thanks for looking.
I can't think of a way to do it, and worse I can think of migration paths that it might break (if we think it's important to support -X in the transition from builds with no var that add a var, it seems reasonable to think it's also important to support -X in the transition from builds with a const to builds with a var).
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?go version go1.8.3 darwin/amd64
What operating system and processor architecture are you using (
go env
)?What did you do?
Created a file main.go:
And ran the following command:
go run -ldflags '-X main.Forename=Bob -X main.Surname=Smith' main.go
What did you expect to see?
An error that
main.Surname
is const and could not be overridden, orWhat did you see instead?
The text was updated successfully, but these errors were encountered: