DebugIf: only test function when tag is enabled

This commit is contained in:
Alexander Neumann 2015-03-15 14:19:37 +01:00
parent 6aed4035f5
commit c9ee79fc54

View file

@ -173,6 +173,11 @@ func Break(tag string) {
// is contained in the DEBUG_BREAK environment variable and the return value of
// fn is true.
func BreakIf(tag string, fn func() bool) {
// check if breaking is enabled
if v, ok := opts.breaks[tag]; !ok || !v {
return
}
if fn() {
Break(tag)
}