Quote non-string values if necessary

This commit is contained in:
Paul Seiffert
2017-07-12 17:15:13 +02:00
parent 10e5e38b53
commit b9cfd82645
2 changed files with 17 additions and 1 deletions
+6 -1
View File
@@ -184,7 +184,12 @@ func (f *TextFormatter) appendValue(b *bytes.Buffer, value interface{}) {
b.WriteString(f.quoteString(errmsg))
}
default:
fmt.Fprint(b, value)
s := fmt.Sprint(value)
if !f.needsQuoting(s) {
b.WriteString(s)
} else {
b.WriteString(f.quoteString(s))
}
}
}