1
0
mirror of https://github.com/golang/go synced 2024-11-23 19:30:05 -07:00

encoding/json: eliminate superfluous space in Decoder.Token error messages

The existing Decoder.tokenError implementation creates its error messages by
concatenating "invalid character " + quoteChar(c) + " " + context. All context
values however already starts with space leading to error messages containing
two spaces.

This change removes the extra space from the concatenation, reverting the prior
space removal from each context.
This commit is contained in:
Philip Børgesen 2018-08-21 09:47:35 +09:00 committed by GitHub
parent 24a77743e6
commit 6db7e1991b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -459,19 +459,19 @@ func (dec *Decoder) tokenError(c byte) (Token, error) {
var context string
switch dec.tokenState {
case tokenTopValue:
context = "looking for beginning of value"
context = " looking for beginning of value"
case tokenArrayStart, tokenArrayValue, tokenObjectValue:
context = "looking for beginning of value"
context = " looking for beginning of value"
case tokenArrayComma:
context = "after array element"
context = " after array element"
case tokenObjectKey:
context = "looking for beginning of object key string"
context = " looking for beginning of object key string"
case tokenObjectColon:
context = "after object key"
context = " after object key"
case tokenObjectComma:
context = "after object key:value pair"
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