Desired behaviour
When building a go module, it is useful to have a version string "burned" into the binary.
In go, this is accomplished by using the go tool link option -X, via the go build option -ldflags.
E.g.: go build -ldflags="-X BUILD_VERSION=${VERSION}"
That command tells the linker to use the value in the bash variable VERSION as the initial value for the go variable BUILD_VERSION.
Current behaviour
Although the -ldflags line is used internally in the gopy code, and passed to the go build command, it is hard-coded to set just the -s and -w options, based on the gopy option --symbols.
|
args = append(args, "-ldflags=-s -w") |
Possible solution
Add a new gopy build option --ldflags that would pass its value on to go build.
The -w and -s flags could be de-duplicated if the gopy --symbols is set, and those flags were also included in the --ldflags value.
Development
I plan to fork the project and fix this for my own requirements shortly, and would be grateful if a contributor could revierw the change once tested, and see whether they consider it a useful enhancement, to be merged into the main project.
Desired behaviour
When building a go module, it is useful to have a version string "burned" into the binary.
In go, this is accomplished by using the
go tool linkoption-X, via thego buildoption-ldflags.E.g.:
go build -ldflags="-X BUILD_VERSION=${VERSION}"That command tells the linker to use the value in the bash variable
VERSIONas the initial value for the go variableBUILD_VERSION.Current behaviour
Although the -ldflags line is used internally in the gopy code, and passed to the
go buildcommand, it is hard-coded to set just the-sand-woptions, based on the gopy option--symbols.gopy/cmd_build.go
Line 193 in 1d7f3a2
Possible solution
Add a new gopy build option
--ldflagsthat would pass its value on togo build.The
-wand-sflags could be de-duplicated if the gopy--symbolsis set, and those flags were also included in the--ldflagsvalue.Development
I plan to fork the project and fix this for my own requirements shortly, and would be grateful if a contributor could revierw the change once tested, and see whether they consider it a useful enhancement, to be merged into the main project.