From 754bfa9e83e72e4c105ff3eac93eba63302565f4 Mon Sep 17 00:00:00 2001 From: Antoine Grondin Date: Sat, 16 Apr 2016 13:48:56 +0530 Subject: [PATCH] match name to semantic in `needsQuoting` fixes #196 --- text_formatter.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/text_formatter.go b/text_formatter.go index 06ef202..6afd0e0 100644 --- a/text_formatter.go +++ b/text_formatter.go @@ -128,10 +128,10 @@ func needsQuoting(text string) bool { (ch >= 'A' && ch <= 'Z') || (ch >= '0' && ch <= '9') || ch == '-' || ch == '.') { - return false + return true } } - return true + return false } func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interface{}) { @@ -141,14 +141,14 @@ func (f *TextFormatter) appendKeyValue(b *bytes.Buffer, key string, value interf switch value := value.(type) { case string: - if needsQuoting(value) { + if !needsQuoting(value) { b.WriteString(value) } else { fmt.Fprintf(b, "%q", value) } case error: errmsg := value.Error() - if needsQuoting(errmsg) { + if !needsQuoting(errmsg) { b.WriteString(errmsg) } else { fmt.Fprintf(b, "%q", value)