die: linter feedback fixes.

This commit is contained in:
2025-11-15 15:55:17 -08:00
parent ddf26e00af
commit a37d28e3d7
2 changed files with 6 additions and 17 deletions

View File

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

View File

@@ -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 package die
import ( import (
@@ -15,15 +16,15 @@ func If(err error) {
} }
// With prints the message to stderr, appending a newline, and exits. // 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) out := fmt.Sprintf("[!] %s\n", fstr)
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. // 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 { if cond {
With(fstr, args...) With(fstr, args)
} }
} }