Skip to content

Commit

Permalink
Merge pull request #22 from kamatama41/remove-null
Browse files Browse the repository at this point in the history
Add a nil check for the json conversion
  • Loading branch information
kamatama41 authored Jul 23, 2019
2 parents b3f40f6 + 5ab2365 commit 8f8e676
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"log"
"net/http"
"os"
"reflect"
"text/template"
"time"

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 8f8e676

Please sign in to comment.