first plugin support.

Module organization requires a better structure to decouple definitions and implementations
This commit is contained in:
2024-06-09 07:41:56 +02:00
parent 8eb2d77ea3
commit 29bc2c62a3
3 changed files with 134 additions and 0 deletions
+30
View File
@@ -0,0 +1,30 @@
// Copyright (c) 2024 Celestino Amoroso (celestino.amoroso@gmail.com).
// All rights reserved.
// plugin.go
package expr
import (
"fmt"
"plugin"
)
var pluginRegister map[string]*plugin.Plugin
func registerPlugin(name string, p *plugin.Plugin) (err error) {
if pluginExists(name) {
err = fmt.Errorf("plugin %q already loaded", name)
} else {
pluginRegister[name] = p
}
return
}
func pluginExists(name string) (exists bool) {
_, exists = pluginRegister[name]
return
}
func init() {
pluginRegister = make(map[string]*plugin.Plugin)
}