From 59334482bb4737998d85b4ab6e1e23cc54053a49 Mon Sep 17 00:00:00 2001 From: yory8 <> Date: Mon, 16 Sep 2019 12:51:33 +0200 Subject: [PATCH] fix: handle missing histfile correctly --- main.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/main.go b/main.go index 9e21567..a690e0d 100644 --- a/main.go +++ b/main.go @@ -53,10 +53,13 @@ func main() { var history []string b, err := ioutil.ReadFile(histfile) if err != nil { - log.Fatalf("Failure reading history file: %s", err) - } - if err := json.Unmarshal(b, &history); err != nil { - log.Fatalf("Failure parsing history: %s", err) + if !os.IsNotExist(err) { + log.Fatalf("Failure reading history file: %s", err) + } + } else { + if err := json.Unmarshal(b, &history); err != nil { + log.Fatalf("Failure parsing history: %s", err) + } } if *asDemon {