I'm using the go plugin package, and following the guides, they say that I should create an iso file using the buildmode=plugin
and the output should have the extension so
. Is this a rule of thumb? Should I always add the extension? Or is it a matter of taste?
Thanks!
Generally, plugins (sometimes called shared/dynamic libraries) have an extension dependent on the platform they run on.
For Windows, that extension tends to be .dll
(for 'Dynamic Link Library'). However, at the time of writing, Go doesn't support Windows plugins.
For Linux/BSD systems, that extension tends to be .so
(for 'Shared Object') This is what the Go docs recommend you use.
Following the documentation for the plugin
package, that would look something like this (on Linux):
// after go build -buildmode=plugin -o plugin_name.so
p, err := plugin.Open("plugin_name.so")
if err != nil {
panic(err)
}
v, err := p.Lookup("V")
if err != nil {
panic(err)
}
f, err := p.Lookup("F")
if err != nil {
panic(err)
}
*v.(*int) = 7
f.(func())() // prints "Hello, number 7"
In short: use .so
.