You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
347 B
Go

4 years ago
package exit
import (
"fmt"
"os"
"strings"
)
func Exit(status int) {
os.Exit(status)
}
func WithMessage(status int, t string, args ...interface{}) {
t = strings.TrimSpace(t) + "\n"
out := os.Stdout
if status != 0 {
out = os.Stderr
}
if len(args) > 0 {
fmt.Fprintf(out, t, args...)
} else {
fmt.Fprint(out, t)
}
Exit(status)
}