From f50a75042edc9654fa5df809fcbf56e5c49b55b4 Mon Sep 17 00:00:00 2001 From: Akihiro Harai Date: Fri, 16 Oct 2020 09:42:32 +0900 Subject: [PATCH] Create nudge file automatically #6 --- nudge.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/nudge.go b/nudge.go index be7afd6..dd0b951 100644 --- a/nudge.go +++ b/nudge.go @@ -203,6 +203,15 @@ type nudger struct { } func newNudger(nudgeFile string) *nudger { + if _, err := os.Stat(nudgeFile); err != nil { + f, err := os.Create(nudgeFile) + if err != nil { + log.Fatal("unable to create nudge file", zap.Error(err)) + } + log.Info("no nudge file found. created.", zap.String("path", nudgeFile)) + f.Close() + } + return &nudger{path: nudgeFile, first: true} }