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
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
I expect to be able to use -ldflags="-X importpath.guestDummy" to set a build time variable when compiling with -buildmode=plugin ; as I can do when compiling regular binaries with -ldflags="-X main.hostDummy"
What did you see instead?
In the context of plugins importpath is variable and depends on the building context. I found that I can have a fixed behavior when using -pluginpath ldflags. But this flag is not well documented:
-pluginpath string
full path name for plugin
Can I use it confidently is this context? is this the good pattern to set a build time variable in plugins?
The text was updated successfully, but these errors were encountered:
Ideally no-one but cmd/go sets -pluginpath. But -X is widely used. I suppose for plugins we could rewrite in cmd/link any value passed in as '-X main.val' to '-X whateverthepluginnameis.val'.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?What operating system and processor architecture are you using (
go env
)?What did you do?
$GOPATH/src/issue_ldflags/host.go
$GOPATH/src/issue_ldflags/guest.go
$GOPATH/src/issue_ldflags/Makefile
If possible, provide a recipe for reproducing the error.
A complete runnable program is good.
A link on play.golang.org is best.
What did you expect to see?
I expect to be able to use
-ldflags="-X importpath.guestDummy"
to set a build time variable when compiling with-buildmode=plugin
; as I can do when compiling regular binaries with-ldflags="-X main.hostDummy"
What did you see instead?
In the context of plugins
importpath
is variable and depends on the building context. I found that I can have a fixed behavior when using-pluginpath
ldflags. But this flag is not well documented:Can I use it confidently is this context? is this the good pattern to set a build time variable in plugins?
The text was updated successfully, but these errors were encountered: