Add boolean function to die.

This commit is contained in:
Kyle Isom 2016-04-28 14:15:22 -07:00
parent 8ec54bb0b3
commit f7bc97405a
1 changed files with 7 additions and 0 deletions

View File

@ -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...)
}
}