diff --git a/.golangci.yml b/.golangci.yml index 22c779249b00..2a3d7af9f21a 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -4,6 +4,7 @@ linters: - depguard - dogsled - durationcheck + - errchkjson - exportloopref # Checks for pointers to enclosing loop variables - gocyclo - gofumpt diff --git a/templates/templates.go b/templates/templates.go index deb043299dbe..3a7ec59e5f6d 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()) },