Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package nucleus
import (
"fmt"
"os"
"plugin"
)
type SBIGreeter interface {
SBIHello()
}
func SBILoader () {
modPath := "/Users/mls/go/src/code.fbi.h-da.de/cocsn/byowsbi/byowsbi.o"
// open the so file that contains the SBI-plugin as step before loading the symbols
plug, err := plugin.Open(modPath)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// loading the symbols
sbiModule, err := plug.Lookup("SBIGreeter")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Assert the loaded symbol
var sbigreeter SBIGreeter
sbigreeter, ok := sbiModule.(SBIGreeter)
if !ok {
fmt.Println("unexpected type from module symbol")
os.Exit(1)
}
// use me!
sbigreeter.SBIHello()
}