Hi, I am using plugin package to implement a feature of my project recently, But some behavior confuses me.
#1 interface main.go: type PluginType interface{ GetVersion() string } func main() { plugFile, err := plugin.Open(filepath.Join("plugins", "plugin_sample.so")) if err != nil { fmt.Println("Fails to load plugins") fmt.Println(err) return } plugTarget, err := plugFile.Lookup("PluginTarget") if err != nil { fmt.Println("Fails to get target veriable") fmt.Println(err) return } plug, ok := plugTarget.(PluginType) if !ok { fmt.Println("Assert convert fails") return } fmt.Println("plugin version:", plug.GetVersion()) } if I write plugin_sample.go like this ``` package main type pluginType struct{} var PluginTarget *pluginType = &pluginType{} func (v *pluginType) GetVersion() string { return "aaaaaaaaaaaa" } ``` then go build -buildmode=plugin -o plugins/plugin_sample.so plugin_sample.go go run main.go It will print `Assert convert fails` But If I write like ``` package main type pluginType struct{} var PluginTarget pluginType func (v pluginType) GetVersion() string { return "aaaaaaaaaaaa" } ``` It will print `plugin version: aaaaaaaaaaaa` as expected. Is this a bug of plugin package of golang? #2 I notice buildmode=plugin only support Linux, is there any plan to support Macos in the feture? I am using go1.12. Thanks Teng -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.