diff --git a/main.go b/main.go index a5d7488..353815a 100644 --- a/main.go +++ b/main.go @@ -3,6 +3,7 @@ package main import ( "context" "encoding/json" + "flag" "log" "time" @@ -21,6 +22,18 @@ type CountLiveAnchors struct { CountMap string `xorm:"count_map"` } +func getArgsStartTime() time.Time { + date := flag.Arg(0) + if date != "" { + panic("please input date eg. '2020-11-30 16:29:17'") + } + start, err := time.ParseInLocation("2006-01-02 15:04:03", date, time.Local) + if err != nil { + panic(err) + } + return start +} + func main() { mdb := database.NewStatisticsDB("mongodb://sg-board1.livenono.com:27018") @@ -31,7 +44,8 @@ func main() { cla := engine.Table("count_live_anchors") - start, err := time.ParseInLocation("2006-01-02 15:04:03", "2020-11-30 16:29:17", time.Local) + start := getArgsStartTime() + // start, err := time.ParseInLocation("2006-01-02 15:04:03", "2020-11-30 16:29:17", time.Local) if err != nil { panic(err) }