|
пре 8 година | |
---|---|---|
base64Encode | пре 8 година | |
pluginSrc | пре 8 година | |
README.md | пре 8 година | |
buildAndRun.sh | пре 8 година | |
index.html | пре 8 година | |
lca.jpg | пре 8 година | |
main.go | пре 8 година |
Run with:
./buildAndRun.sh
To activate the plugins, move the .so
files from the
plugins.available
directory to the plugins
directory.
Based on dlfcn.h
(dynamic linking) with cgo
Only two functions: Open(path string) (*Plugin, error)
and (p
*Plugin) Lookup(symName string) (Symbol, error)
Two types: Plugin
, Symbol
Nothing special on the code of the plugin, only the
-buildmode=plugin
build option
Example (from the doc):
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"