Skip to content
Snippets Groups Projects

Draft: Resolve "Create interfaces for internal data structure"

Closed Ghost User requested to merge 60-create-interfaces-for-internal-data-structure into develop
+ 10
7
@@ -6,11 +6,12 @@ import (
"plugin"
)
type SBIGreeter interface {
SBIHello()
type SBIInterface interface {
Hello() string
AddClient()
}
func SBILoader () {
func SBILoader () error {
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
@@ -21,21 +22,23 @@ func SBILoader () {
}
// loading the symbols
sbiModule, err := plug.Lookup("SBIGreeter")
sbiModule, err := plug.Lookup("SBIInterface")
if err != nil {
fmt.Println(err)
os.Exit(1)
}
// Assert the loaded symbol
var sbigreeter SBIGreeter
sbigreeter, ok := sbiModule.(SBIGreeter)
var sbi SBIInterface
sbi, ok := sbiModule.(SBIInterface)
if !ok {
fmt.Println("unexpected type from module symbol")
fmt.Println(ok)
os.Exit(1)
}
// use me!
sbigreeter.SBIHello()
fmt.Print(sbi.Hello())
sbi.AddClient()
}
Loading