зеркало из https://github.com/mislav/hub.git
ui Printf functions: handle errors by dying
This commit is contained in:
Родитель
cc38879bd6
Коммит
116f08f1f9
45
ui/ui.go
45
ui/ui.go
|
@ -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 {
|
||||
|
|
Загрузка…
Ссылка в новой задаче