From 283d65413db75edbc4691c4fecf23228509436f0 Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Fri, 27 Nov 2020 13:55:27 -0800 Subject: [PATCH] encoding/json: revert "add "json: " prefix to SyntaxError messages" This reverts commit 6af088bfc66c13143c9ef46b4cf0805df77a8fbe. Reason for revert: Broke many tests inside Google which implies many tests were broken outside of Google as well. The tests may be brittle but still would require work to change and it's not clear it's worth the benefit. Updates #36221 Fixes #42675 Change-Id: Id3a14eb37e7119f5abe50e80dfbf120fdc44db72 Reviewed-on: https://go-review.googlesource.com/c/go/+/273747 Run-TryBot: Joe Tsai TryBot-Result: Go Bot Reviewed-by: Russ Cox Reviewed-by: Joe Tsai Trust: Joe Tsai --- doc/go1.16.html | 6 ------ src/cmd/go/testdata/script/mod_proxy_invalid.txt | 4 ++-- src/cmd/go/testdata/script/mod_query_empty.txt | 2 +- src/encoding/json/scanner.go | 2 +- src/html/template/escape_test.go | 2 +- 5 files changed, 5 insertions(+), 11 deletions(-) diff --git a/doc/go1.16.html b/doc/go1.16.html index 0c1fe5b381..ffdbc97c62 100644 --- a/doc/go1.16.html +++ b/doc/go1.16.html @@ -454,12 +454,6 @@ Do not send CLs removing the interior tags from such phrases.
encoding/json
-

- The error message for - SyntaxError - now begins with "json: ", matching the other errors in the package. -

-

TODO: https://golang.org/cl/234818: allow semicolon in field key / struct tag

diff --git a/src/cmd/go/testdata/script/mod_proxy_invalid.txt b/src/cmd/go/testdata/script/mod_proxy_invalid.txt index b9418b4df1..6427cc1527 100644 --- a/src/cmd/go/testdata/script/mod_proxy_invalid.txt +++ b/src/cmd/go/testdata/script/mod_proxy_invalid.txt @@ -2,7 +2,7 @@ env GO111MODULE=on env GOPROXY=$GOPROXY/invalid ! go list -m rsc.io/quote@latest -stderr '^go list -m: module rsc.io/quote: invalid response from proxy "'$GOPROXY'": json: invalid character ''i'' looking for beginning of value$' +stderr '^go list -m: module rsc.io/quote: invalid response from proxy "'$GOPROXY'": invalid character ''i'' looking for beginning of value$' ! 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'": json: 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'": invalid character ''i'' looking for beginning of value$' diff --git a/src/cmd/go/testdata/script/mod_query_empty.txt b/src/cmd/go/testdata/script/mod_query_empty.txt index 1f13d7ad69..f8b6e3e97e 100644 --- a/src/cmd/go/testdata/script/mod_query_empty.txt +++ b/src/cmd/go/testdata/script/mod_query_empty.txt @@ -40,7 +40,7 @@ env GOPROXY=file:///$WORK/gatekeeper chmod 0000 $WORK/gatekeeper/example.com/join/subpkg/@latest cp go.mod.orig go.mod ! go get -d example.com/join/subpkg -stderr 'go get: module example.com/join/subpkg: (invalid response from proxy ".+": json: invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)' +stderr 'go get: module example.com/join/subpkg: (invalid response from proxy ".+": invalid character .+|reading file://.*/gatekeeper/example.com/join/subpkg/@latest: .+)' -- go.mod.orig -- module example.com/othermodule diff --git a/src/encoding/json/scanner.go b/src/encoding/json/scanner.go index c3f5f6372d..9dc1903e2d 100644 --- a/src/encoding/json/scanner.go +++ b/src/encoding/json/scanner.go @@ -47,7 +47,7 @@ type SyntaxError struct { Offset int64 // error occurred after reading Offset bytes } -func (e *SyntaxError) Error() string { return "json: " + e.msg } +func (e *SyntaxError) Error() string { return e.msg } // A scanner is a JSON scanning state machine. // Callers call scan.reset and then pass bytes in one at a time diff --git a/src/html/template/escape_test.go b/src/html/template/escape_test.go index b6031ea60a..fbc84a7592 100644 --- a/src/html/template/escape_test.go +++ b/src/html/template/escape_test.go @@ -243,7 +243,7 @@ func TestEscape(t *testing.T) { { "badMarshaler", `