diff --git a/.golangci.yml b/.golangci.yml index c1ca4b920e..b7be9e413a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -5,6 +5,7 @@ linters: - dogsled - dupword # Detects duplicate words. - durationcheck + - errchkjson - exportloopref # Detects pointers to enclosing loop variables. - gocritic # Metalinter; detects bugs, performance, and styling issues. - gocyclo diff --git a/templates/templates.go b/templates/templates.go index f0b62260ee..c1366be1cd 100644 --- a/templates/templates.go +++ b/templates/templates.go @@ -14,7 +14,11 @@ var basicFunctions = template.FuncMap{ buf := &bytes.Buffer{} enc := json.NewEncoder(buf) enc.SetEscapeHTML(false) - enc.Encode(v) + err := enc.Encode(v) + if err != nil { + panic(err) + } + // Remove the trailing new line added by the encoder return strings.TrimSpace(buf.String()) },