Fix calls to die.With.
This commit is contained in:
12
dbg/dbg.go
12
dbg/dbg.go
@@ -55,22 +55,22 @@ func To(w io.WriteCloser) *DebugPrinter {
|
||||
}
|
||||
|
||||
// Print calls fmt.Print if Enabled is true.
|
||||
func (dbg *DebugPrinter) Print(v any) {
|
||||
func (dbg *DebugPrinter) Print(v ...any) {
|
||||
if dbg.Enabled {
|
||||
fmt.Fprint(dbg.out, v)
|
||||
fmt.Fprint(dbg.out, v...)
|
||||
}
|
||||
}
|
||||
|
||||
// Println calls fmt.Println if Enabled is true.
|
||||
func (dbg *DebugPrinter) Println(v any) {
|
||||
func (dbg *DebugPrinter) Println(v ...any) {
|
||||
if dbg.Enabled {
|
||||
fmt.Fprintln(dbg.out, v)
|
||||
fmt.Fprintln(dbg.out, v...)
|
||||
}
|
||||
}
|
||||
|
||||
// Printf calls fmt.Printf if Enabled is true.
|
||||
func (dbg *DebugPrinter) Printf(format string, v any) {
|
||||
func (dbg *DebugPrinter) Printf(format string, v ...any) {
|
||||
if dbg.Enabled {
|
||||
fmt.Fprintf(dbg.out, format, v)
|
||||
fmt.Fprintf(dbg.out, format, v...)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,15 +16,15 @@ func If(err error) {
|
||||
}
|
||||
|
||||
// With prints the message to stderr, appending a newline, and exits.
|
||||
func With(fstr string, args any) {
|
||||
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 any) {
|
||||
func When(cond bool, fstr string, args ...any) {
|
||||
if cond {
|
||||
With(fstr, args)
|
||||
With(fstr, args...)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user