mirror of https://github.com/golang/go.git
encoding/json: add "json: " prefix to SyntaxError messages
The other named errors - UnmarshalTypeError, etc - in this package do the same, so we should prepend the package prefix to error messages for consistency. Add a note to the release docs in case this is interpreted as a breaking change. Fixes #36221. Change-Id: Ie24b532bbf9812e108c259fa377e2a6b64319ed4 Reviewed-on: https://go-review.googlesource.com/c/go/+/263619 Run-TryBot: Kevin Burke <kev@inburke.com> TryBot-Result: Go Bot <gobot@golang.org> Trust: Kevin Burke <kev@inburke.com> Trust: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
parent
612a363bef
commit
6af088bfc6
|
|
@ -216,6 +216,14 @@ Do not send CLs removing the interior tags from such phrases.
|
||||||
of a malformed certificate.
|
of a malformed certificate.
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
|
<h3 id="encoding/json"><a href="/pkg/encoding/json">encoding/json</a></h3>
|
||||||
|
|
||||||
|
<p><!-- CL 263619 -->
|
||||||
|
The error message for
|
||||||
|
<a href="/pkg/encoding/json/#SyntaxError">SyntaxError</a>
|
||||||
|
now begins with "json: ", matching the other errors in the package.
|
||||||
|
</p>
|
||||||
|
|
||||||
<h3 id="net"><a href="/pkg/net/">net</a></h3>
|
<h3 id="net"><a href="/pkg/net/">net</a></h3>
|
||||||
|
|
||||||
<p><!-- CL 250357 -->
|
<p><!-- CL 250357 -->
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ env GO111MODULE=on
|
||||||
env GOPROXY=$GOPROXY/invalid
|
env GOPROXY=$GOPROXY/invalid
|
||||||
|
|
||||||
! go list -m rsc.io/quote@latest
|
! go list -m rsc.io/quote@latest
|
||||||
stderr '^go list -m: module rsc.io/quote: invalid response from proxy "'$GOPROXY'": invalid character ''i'' looking for beginning of value$'
|
stderr '^go list -m: module rsc.io/quote: invalid response from proxy "'$GOPROXY'": json: invalid character ''i'' looking for beginning of value$'
|
||||||
|
|
||||||
! go list -m rsc.io/quote@1.5.2
|
! go list -m rsc.io/quote@1.5.2
|
||||||
stderr '^go list -m: rsc.io/quote@1.5.2: invalid version: invalid response from proxy "'$GOPROXY'": invalid character ''i'' looking for beginning of value$'
|
stderr '^go list -m: rsc.io/quote@1.5.2: invalid version: invalid response from proxy "'$GOPROXY'": json: invalid character ''i'' looking for beginning of value$'
|
||||||
|
|
|
||||||
|
|
@ -40,7 +40,7 @@ env GOPROXY=file:///$WORK/gatekeeper
|
||||||
chmod 0000 $WORK/gatekeeper/example.com/join/subpkg/@latest
|
chmod 0000 $WORK/gatekeeper/example.com/join/subpkg/@latest
|
||||||
cp go.mod.orig go.mod
|
cp go.mod.orig go.mod
|
||||||
! go get -d example.com/join/subpkg
|
! go get -d example.com/join/subpkg
|
||||||
stderr 'go get example.com/join/subpkg: module example.com/join/subpkg: (invalid response from proxy ".+": invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)'
|
stderr 'go get example.com/join/subpkg: module example.com/join/subpkg: (invalid response from proxy ".+": json: invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)'
|
||||||
|
|
||||||
-- go.mod.orig --
|
-- go.mod.orig --
|
||||||
module example.com/othermodule
|
module example.com/othermodule
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@ type SyntaxError struct {
|
||||||
Offset int64 // error occurred after reading Offset bytes
|
Offset int64 // error occurred after reading Offset bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *SyntaxError) Error() string { return e.msg }
|
func (e *SyntaxError) Error() string { return "json: " + e.msg }
|
||||||
|
|
||||||
// A scanner is a JSON scanning state machine.
|
// A scanner is a JSON scanning state machine.
|
||||||
// Callers call scan.reset and then pass bytes in one at a time
|
// Callers call scan.reset and then pass bytes in one at a time
|
||||||
|
|
|
||||||
|
|
@ -243,7 +243,7 @@ func TestEscape(t *testing.T) {
|
||||||
{
|
{
|
||||||
"badMarshaler",
|
"badMarshaler",
|
||||||
`<button onclick='alert(1/{{.B}}in numbers)'>`,
|
`<button onclick='alert(1/{{.B}}in numbers)'>`,
|
||||||
`<button onclick='alert(1/ /* json: error calling MarshalJSON for type *template.badMarshaler: invalid character 'f' looking for beginning of object key string */null in numbers)'>`,
|
`<button onclick='alert(1/ /* json: error calling MarshalJSON for type *template.badMarshaler: json: invalid character 'f' looking for beginning of object key string */null in numbers)'>`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"jsMarshaler",
|
"jsMarshaler",
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue