Merge pull request #63 from icholy/master

improve error output formatting
This commit is contained in:
Aaron Raddon 2018-06-23 07:05:43 -07:00 committed by GitHub
commit 4109f1d4ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

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