Hello,
I'm trying to use the -X ldflag to set a string at compile time. I can do this successfully if the string is in the main package but it does not work if the string is in a subpackage.
For illustration purposes, I have prepared a simple test project
The build.sh file contains the build string. It contains one useful line, which I'll repeat it here:
go build -ldflags "-X 'main.A=foo' -X 'sub.B=bar'"
When built, the main function will print out the A string correctly but the B string is unset.
What am I doing wrong?
Regards
Stephen