New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
plugin: can not lookup exported function #17141
Comments
same here What did you do?plugin.go
main.go
What did you expect to see?prints 'hello, world' What did you see instead?
Does this issue reproduce with the latest release (go1.7.1)?tip System details
|
(I was not expecting bug reports this quickly. I'll take a look on Monday.) |
The bug is that "go build -buildmode plugin plugin.go" will incorrectly use
"command-line-argument" as the package name.
|
There is also an issue (for me), if I use a path when opening the plugin: http://sprunge.us/STRM |
(btw: It's pretty awesome that this actually happened :) ) |
Awesome feature! Quick workaround: diff --git a/src/plugin/plugin_dlopen.go b/src/plugin/plugin_dlopen.go
index 45c0eeb..db667f9 100644
--- a/src/plugin/plugin_dlopen.go
+++ b/src/plugin/plugin_dlopen.go
@@ -33,6 +33,7 @@ import "C"
import (
"errors"
+ libpath "path"
"sync"
"unsafe"
)
@@ -58,6 +59,7 @@ func open(name string) (*Plugin, error) {
// TODO(crawshaw): look for plugin note, confirm it is a Go plugin
// and it was built with the correct toolchain.
// TODO(crawshaw): get full plugin name from note.
+ name = libpath.Base(name)
if len(name) > 3 && name[len(name)-3:] == ".so" {
name = name[:len(name)-3]
} |
I didn't find that the workaround above worked for me. For me, the unexpected thing here is that the file name of the dynamically loaded module is important. The plugin documentation seems to indicate that the path name is not important,
|
I believe this was fixed by 9da7058. |
Please answer these questions before submitting your issue. Thanks!
What did you do?
Build a plugin and tried to lookup a function.
plugin.go:
main.go:
Commands:
go build -buildmode=plugin plugin.go
go run main.go
What did you expect to see?
No errors.
What did you see instead?
Trying the example code from the plugin.Symbol documentation I get a similiar error:
System details
The text was updated successfully, but these errors were encountered: