Skip to content
Snippets Groups Projects
sbi-general.go 699 B
Newer Older
  • Learn to ignore specific revisions
  • 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()
    }