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
Both modules are loaded, and plugin-a init! as well as plugin-b init! are printed to console.
What did you see instead?
Output of go run cmd/main.go:
go: downloading golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2
main
/src <nil>
load plugin-a:
plugin-a init!
&{github.com/fxedel/go-plugin-bug/plugin-a 0x40000160c0 map[]} <nil>
load plugin-b:
<nil> plugin.Open("./build/plugin-b"): plugin was built with a different version of package golang.org/x/xerrors/internal
Further notes
I also tested this with another external package (golang.org/x/sys/unix), which is commented out in my demo repository. I guess that due to the different module cache directory, package paths are different and the Go runtime checks package version using the package path. However, this should not make a difference, as both plugins are built with the same library version (just at different locations).
The text was updated successfully, but these errors were encountered:
use -trimpath if you don't want absolute file paths leaking into the binary.
Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.
Hey @seankhliao, thanks for the reply. Adding -trimpath works, but unfortunately, I cannot always control the build options of the main binary (in particular, I'd like to create a plugin for krakend). I guess this issue is related to (or even duplicates?) #26759.
What version of Go are you using (
go version
)?(Docker golang:1.21.1 image)
Does this issue reproduce with the latest release?
yes (1.12.1 is the latest release)
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
See dockerized setup on fxedel/go-issue-63230.
I have two almost identical Go plugins, which both use an external (non-standard) library:
plugin-a/main.go
:plugin-b/main.go
:go build -v -buildmode=plugin -o build/plugin-a.so ./plugin-a
GOMODCACHE=/tmp go build -v -buildmode=plugin -o build/plugin-b.so ./plugin-b
Both plugins are loaded in my main program:
cmd/main.go
:All files live in the same go module:
go.mod
:go.sum
:What did you expect to see?
Both modules are loaded, and
plugin-a init!
as well asplugin-b init!
are printed to console.What did you see instead?
Output of
go run cmd/main.go
:Further notes
I also tested this with another external package (
golang.org/x/sys/unix
), which is commented out in my demo repository. I guess that due to the different module cache directory, package paths are different and the Go runtime checks package version using the package path. However, this should not make a difference, as both plugins are built with the same library version (just at different locations).The text was updated successfully, but these errors were encountered: