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
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.
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.
The text was updated successfully, but these errors were encountered:
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 thego 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 variableBUILD_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
.gopy/cmd_build.go
Line 193 in 1d7f3a2
Possible solution
Add a new gopy build option
--ldflags
that would pass its value on togo 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.
The text was updated successfully, but these errors were encountered: