2
2
mirror of https://github.com/octoleo/restic.git synced 2024-05-28 14:40:49 +00:00
restic/internal/debug/hooks.go

30 lines
384 B
Go
Raw Normal View History

2022-03-28 20:23:47 +00:00
//go:build debug
2018-10-07 18:40:18 +00:00
// +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)
}