improve error output formatting

This commit is contained in:
Ilia Choly 2018-06-19 11:39:29 -04:00
parent 6135c1994e
commit 0963c6f518

View File

@ -3,6 +3,7 @@ package main
import (
"flag"
"fmt"
"os"
"time"
"github.com/apcera/termtables"
@ -32,7 +33,7 @@ func main() {
layout, err := dateparse.ParseFormat(datestr)
if err != nil {
panic(err.Error())
fatal(err)
}
zonename, _ := time.Now().In(time.Local).Zone()
@ -44,7 +45,7 @@ func main() {
// time-parsing in go
l, err := time.LoadLocation(timezone)
if err != nil {
panic(err.Error())
fatal(err)
}
loc = l
zonename, _ := time.Now().In(l).Zone()
@ -77,10 +78,6 @@ func main() {
fmt.Println(table.Render())
}
func stuff() (string, string) {
return "more", "stuff"
}
type parser func(datestr string, loc *time.Location, utc bool) string
func parseLocal(datestr string, loc *time.Location, utc bool) string {
@ -127,3 +124,8 @@ func parseStrict(datestr string, loc *time.Location, utc bool) string {
}
return t.String()
}
func fatal(err error) {
fmt.Printf("fatal: %s\n", err)
os.Exit(1)
}