diff --git a/die/README.md b/die/README.md deleted file mode 100644 index d509d84..0000000 --- a/die/README.md +++ /dev/null @@ -1,12 +0,0 @@ -Simple fatal utilities for Go programs. - -``` - result, err := doSomething() - die.If(err) - - ok := processResult(result) - if !ok { - die.With("failed to process result %s", result.Name) - } -``` - diff --git a/die/die.go b/die/die.go index 7bda7f6..5ecc0a8 100644 --- a/die/die.go +++ b/die/die.go @@ -1,4 +1,5 @@ -// Package die contains utilities for fatal error handling. +// Package die contains utilities for fatal error handling. It +// presents simple fatal utilities for Go programs. package die import ( @@ -15,15 +16,15 @@ func If(err error) { } // With prints the message to stderr, appending a newline, and exits. -func With(fstr string, args ...interface{}) { +func With(fstr string, args any) { out := fmt.Sprintf("[!] %s\n", fstr) - fmt.Fprintf(os.Stderr, out, args...) + 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{}) { +func When(cond bool, fstr string, args any) { if cond { - With(fstr, args...) + With(fstr, args) } }