From 14338a3f5a750aa502fb2769a0397f8989e5c461 Mon Sep 17 00:00:00 2001 From: eson Date: Wed, 9 Dec 2020 10:54:13 +0800 Subject: [PATCH] bug fix. and test success! --- main.go | 6 ++++-- main_test.go | 7 +++++++ 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 main_test.go diff --git a/main.go b/main.go index b05b9d8..733f4a2 100644 --- a/main.go +++ b/main.go @@ -26,13 +26,15 @@ func getArgsStartTime() time.Time { flag.Parse() date := flag.Arg(0) if date == "" { - // log.Println(flag.) + log.Println("args", flag.Args()) panic("please input date eg. '2020-11-30 16:29:17'") } - start, err := time.ParseInLocation("2006-01-02 15:04:03", date, time.Local) + + start, err := time.ParseInLocation("2006-01-02 15:04:05", date, time.Local) if err != nil { panic(err) } + return start } diff --git a/main_test.go b/main_test.go new file mode 100644 index 0000000..ef64976 --- /dev/null +++ b/main_test.go @@ -0,0 +1,7 @@ +package main + +import "testing" + +func TestMain(t *testing.T) { + main() +}