From 5ab23653440b93ec06b598ecb41e328b4c0131b1 Mon Sep 17 00:00:00 2001 From: Shinichi Ishimura Date: Tue, 23 Jul 2019 15:58:30 +0900 Subject: [PATCH] Add a nil check for the json conversion --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index 687faa3..e22dc35 100644 --- a/main.go +++ b/main.go @@ -10,6 +10,7 @@ import ( "log" "net/http" "os" + "reflect" "text/template" "time" @@ -254,6 +255,9 @@ func newConfig() (*config, error) { funcs := map[string]interface{}{ "json": func(in interface{}) (string, error) { + if in == nil || reflect.ValueOf(in).IsNil() { + return "", nil + } b, err := json.Marshal(in) if err != nil { return "", err