feat:插件注册&差分so

This commit is contained in:
songzhibin97
2021-08-21 10:48:44 +08:00
parent 513003a8bb
commit 181b3a985e
4 changed files with 44 additions and 27 deletions

View File

@@ -10,8 +10,29 @@ import (
"os"
"path/filepath"
"plugin"
"sync"
)
var ManagementPlugin = managementPlugin{mp: make(map[string]*plugin.Plugin)}
type managementPlugin struct {
mp map[string]*plugin.Plugin
sync.Mutex
}
func (m *managementPlugin) SetPlugin(key string, p *plugin.Plugin) {
m.Lock()
defer m.Unlock()
m.mp[key] = p
}
func (m *managementPlugin) GetPlugin(key string) (p *plugin.Plugin, ok bool) {
m.Lock()
defer m.Unlock()
p, ok = m.mp[key]
return
}
// LoadPlugin 加载插件 传入path
func LoadPlugin(path string) error {
path, err := filepath.Abs(path)