mirror of
https://github.com/octoleo/restic.git
synced 2024-11-22 21:05:10 +00:00
Add BreakIf function
This commit is contained in:
parent
3d768e39ea
commit
6aed4035f5
@ -148,6 +148,8 @@ func Log(tag string, f string, args ...interface{}) {
|
||||
}
|
||||
}
|
||||
|
||||
// Break stopts the program if the debug tag is active and the string in tag is
|
||||
// contained in the DEBUG_BREAK environment variable.
|
||||
func Break(tag string) {
|
||||
// check if breaking is enabled
|
||||
if v, ok := opts.breaks[tag]; !ok || !v {
|
||||
@ -166,3 +168,12 @@ func Break(tag string) {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
|
||||
// BreakIf stopts the program if the debug tag is active and the string in tag
|
||||
// is contained in the DEBUG_BREAK environment variable and the return value of
|
||||
// fn is true.
|
||||
func BreakIf(tag string, fn func() bool) {
|
||||
if fn() {
|
||||
Break(tag)
|
||||
}
|
||||
}
|
||||
|
@ -5,3 +5,5 @@ package debug
|
||||
func Log(tag string, fmt string, args ...interface{}) {}
|
||||
|
||||
func Break(string) {}
|
||||
|
||||
func BreakIf(string, func() bool) {}
|
||||
|
Loading…
Reference in New Issue
Block a user