From f7bc97405a3ffe31d4f049bd88362a1d7c0fb47d Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Thu, 28 Apr 2016 14:15:22 -0700 Subject: [PATCH] Add boolean function to die. --- die/die.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/die/die.go b/die/die.go index 472d685..7bda7f6 100644 --- a/die/die.go +++ b/die/die.go @@ -20,3 +20,10 @@ func With(fstr string, args ...interface{}) { fmt.Fprintf(os.Stderr, out, args...) 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...) + } +}