From e9896321ad9de748d7c23207962aa836b6a62726 Mon Sep 17 00:00:00 2001 From: Eugene Kalinin Date: Tue, 4 Jul 2017 12:09:00 +0300 Subject: [PATCH] fix #14. added check for nil for non-existing file --- main.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index a6e8b58..3547e68 100644 --- a/main.go +++ b/main.go @@ -147,6 +147,9 @@ func GetHmtlBody(path string) (string, error) { if IsURL(path) { return httpGet(path) } + if _, err := os.Stat(path); os.IsNotExist(err) { + return "", err + } return ConvertMd2Html(path) } @@ -262,7 +265,10 @@ func main() { for i := 1; i <= pathsCount; i++ { toc := <-ch - toc.Print() + // #14, check if there's realy Toc? + if toc != nil { + toc.Print() + } } // read md from stdin