mirror of
https://github.com/octoleo/restic.git
synced 2024-11-10 15:21:03 +00:00
30 lines
384 B
Go
30 lines
384 B
Go
//go:build debug
|
|
// +build debug
|
|
|
|
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)
|
|
}
|