mirror of
				https://github.com/restic/restic.git
				synced 2025-11-04 04:16:58 +00:00 
			
		
		
		
	Moves files
This commit is contained in:
		
							
								
								
									
										28
									
								
								internal/debug/hooks.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										28
									
								
								internal/debug/hooks.go
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,28 @@
 | 
			
		||||
// +build !release
 | 
			
		||||
 | 
			
		||||
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)
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user