ui Printf functions: handle errors by dying

This commit is contained in:
Andrew Janke 2018-12-22 12:27:48 -05:00
Родитель cc38879bd6
Коммит 116f08f1f9
1 изменённых файлов: 35 добавлений и 10 удалений

Просмотреть файл

@ -23,24 +23,49 @@ var (
Default UI = Console{Stdout: Stdout, Stderr: Stderr}
)
func Print(a ...interface{}) (n int, err error) {
return Default.Print(a...)
func Print(a ...interface{}) (n int) {
n, err := Default.Print(a...)
if err != nil {
// If something as basic as printing to stdout fails, just panic and exit
os.Exit(1)
}
return
}
func Printf(format string, a ...interface{}) (n int, err error) {
return Default.Printf(format, a...)
func Printf(format string, a ...interface{}) (n int) {
n, err := Default.Printf(format, a...)
if err != nil {
// If something as basic as printing to stdout fails, just panic and exit
os.Exit(1)
}
return
}
func Println(a ...interface{}) (n int, err error) {
return Default.Println(a...)
func Println(a ...interface{}) (n int) {
n, err := Default.Println(a...)
if err != nil {
// If something as basic as printing to stdout fails, just panic and exit
os.Exit(1)
}
return
}
func Errorf(format string, a ...interface{}) (n int, err error) {
return Default.Errorf(format, a...)
func Errorf(format string, a ...interface{}) (n int) {
n, err := Default.Errorf(format, a...)
if err != nil {
// If something as basic as printing to stderr fails, just panic and exit
os.Exit(1)
}
return
}
func Errorln(a ...interface{}) (n int, err error) {
return Default.Errorln(a...)
func Errorln(a ...interface{}) (n int) {
n, err := Default.Errorln(a...)
if err != nil {
// If something as basic as printing to stderr fails, just panic and exit
os.Exit(1)
}
return
}
func IsTerminal(f *os.File) bool {