2022-03-28 20:23:47 +00:00
|
|
|
//go:build debug
|
2018-10-07 18:40:18 +00:00
|
|
|
// +build debug
|
2015-06-21 15:12:38 +00:00
|
|
|
|
|
|
|
package debug
|
|
|
|
|
|
|
|
var (
|
|
|
|
hooks map[string]func(interface{})
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
hooks = make(map[string]func(interface{}))
|
|
|
|
}
|
|
|
|
|
|
|
|
func Hook(name string, f func(interface{})) {
|
|
|
|
hooks[name] = f
|
|
|
|
}
|
|
|
|
|
|
|
|
func RunHook(name string, context interface{}) {
|
|
|
|
f, ok := hooks[name]
|
|
|
|
if !ok {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
f(context)
|
|
|
|
}
|
|
|
|
|
|
|
|
func RemoveHook(name string) {
|
|
|
|
delete(hooks, name)
|
|
|
|
}
|