From 6af088bfc66c13143c9ef46b4cf0805df77a8fbe Mon Sep 17 00:00:00 2001 From: Kevin Burke Date: Mon, 19 Oct 2020 13:29:40 -0700 Subject: encoding/json: add "json: " prefix to SyntaxError messages MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 TryBot-Result: Go Bot Trust: Kevin Burke Trust: Daniel Martí Reviewed-by: Daniel Martí --- src/encoding/json/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/encoding/json') diff --git a/src/encoding/json/scanner.go b/src/encoding/json/scanner.go index 9dc1903e2d..c3f5f6372d 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 e.msg } +func (e *SyntaxError) Error() string { return "json: " + e.msg } // A scanner is a JSON scanning state machine. // Callers call scan.reset and then pass bytes in one at a time -- cgit v1.3-5-g9baa