]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/json: eliminate superfluous space in Decoder.Token error messages
authorPhilip Børgesen <PhilipBorgesen@users.noreply.github.com>
Tue, 21 Aug 2018 00:52:46 +0000 (00:52 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Tue, 21 Aug 2018 02:26:17 +0000 (02:26 +0000)
The existing Decoder.tokenError implementation creates its error messages by
concatenating "invalid character " + quoteChar(c) + " " + context. All context
values however already start with a space leading to error messages containing
two spaces.

This change removes " " from the concatenation expression.

Fixes #26587

Change-Id: I93d14319396636b2a40d55053bda88c98e94a81a
GitHub-Last-Rev: 6db7e1991b15beee601f558be72a2737070d8f68
GitHub-Pull-Request: golang/go#26588
Reviewed-on: https://go-review.googlesource.com/125775
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Daniel MartĂ­ <mvdan@mvdan.cc>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

src/encoding/json/stream.go

index 75a4270df7de1c018b6b79907d1395032b894fcb..63aa0309555ef9a6bb1ccc95d30bba2172a86583 100644 (file)
@@ -471,7 +471,7 @@ func (dec *Decoder) tokenError(c byte) (Token, error) {
        case tokenObjectComma:
                context = " after object key:value pair"
        }
-       return nil, &SyntaxError{"invalid character " + quoteChar(c) + " " + context, dec.offset()}
+       return nil, &SyntaxError{"invalid character " + quoteChar(c) + context, dec.offset()}
 }
 
 // More reports whether there is another element in the