contracts/support/service.go

34 lines
684 B
Go

package support
import (
"plugin"
"git.fsdpf.net/go/contracts"
)
func GoPluginCore(core string, controllers map[string]contracts.Controller, listens map[string]contracts.ResListener) {
p, err := plugin.Open(core)
if err != nil {
panic(err)
}
if f, err := p.Lookup("RegControllers"); err != nil {
panic(err)
} else if fn, ok := f.(func(map[string]contracts.Controller) error); ok {
fn(controllers)
}
if f, err := p.Lookup("RegListens"); err != nil {
panic(err)
} else if fn, ok := f.(func(map[string]contracts.ResListener) error); ok {
fn(listens)
}
if f, err := p.Lookup("Run"); err != nil {
panic(err)
} else if fn, ok := f.(func()); ok {
fn()
}
}