25 lines
368 B
Go
25 lines
368 B
Go
package lib
|
|
|
|
import (
|
|
"sync"
|
|
)
|
|
|
|
type Action interface{
|
|
RegisterAction()
|
|
}
|
|
|
|
type BaseAction struct {
|
|
actionMap map[string]interface{}
|
|
lock sync.Mutex
|
|
}
|
|
|
|
func (a *BaseAction) init() {
|
|
a.actionMap = make(map[string]interface{})
|
|
}
|
|
|
|
func (a *BaseAction) Reg(idStr string, action interface{}) {
|
|
defer a.lock.Unlock()
|
|
a.lock.Lock()
|
|
a.actionMap[idStr] = action
|
|
}
|