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
go linker reports error: cannot set with -X: not a var of type string.
the ID type may contains complex format, It would be great if the linker supports custom type name,
so i could define methods on it and get type safety.
currently, i must defines the methods as global functions or create a new variable to wrap the linker variable.
varlinkIDstringvarid=ID(linkID)
The text was updated successfully, but these errors were encountered:
zhuah
changed the title
couldn't uses ldflags "-X" on custom type name alias to string: cannot set with -X: not a var of type string
cmd/link: couldn't uses ldflags "-X" on custom type name alias to string: cannot set with -X: not a var of type string
Mar 15, 2021
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I defines a variable with custom type name aliased to string
and go build with
-ldflags="-X pkg.id=aaa.bbb"
.What did you expect to see?
What did you see instead?
go linker reports error: cannot set with -X: not a var of type string.
the
ID
type may contains complex format, It would be great if the linker supports custom type name,so i could define methods on it and get type safety.
currently, i must defines the methods as global functions or create a new variable to wrap the linker variable.
The text was updated successfully, but these errors were encountered: