Add boolean function to die.
This commit is contained in:
parent
8ec54bb0b3
commit
f7bc97405a
|
@ -20,3 +20,10 @@ func With(fstr string, args ...interface{}) {
|
||||||
fmt.Fprintf(os.Stderr, out, args...)
|
fmt.Fprintf(os.Stderr, out, args...)
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// When prints the error to stderr and exits if cond is true.
|
||||||
|
func When(cond bool, fstr string, args ...interface{}) {
|
||||||
|
if cond {
|
||||||
|
With(fstr, args...)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue