aboutsummaryrefslogtreecommitdiff
path: root/src/encoding
diff options
context:
space:
mode:
authorDamien Neil <dneil@google.com>2020-09-14 20:59:50 +0000
committerDamien Neil <dneil@google.com>2020-09-14 21:33:53 +0000
commit506eb0a9b1a7051f64788f330ea26722fa293f3c (patch)
tree67732a5db97a5a3d45688b5aa8ad5409c57cbe9f /src/encoding
parent114719e16e9681bd1001326598ededa719c17944 (diff)
downloadgo-506eb0a9b1a7051f64788f330ea26722fa293f3c.tar.gz
go-506eb0a9b1a7051f64788f330ea26722fa293f3c.zip
Revert "encoding/json: implement Is on SyntaxError"
This reverts CL 253037. Reason for revert: The recommended way to check for a type of error is errors.As. API changes should also start with a proposal. Change-Id: I62896717aa47ed491c2c4775d2b05d80e5e9cde3 Reviewed-on: https://go-review.googlesource.com/c/go/+/254837 Trust: Damien Neil <dneil@google.com> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Diffstat (limited to 'src/encoding')
-rw-r--r--src/encoding/json/scanner.go6
-rw-r--r--src/encoding/json/scanner_test.go9
2 files changed, 0 insertions, 15 deletions
diff --git a/src/encoding/json/scanner.go b/src/encoding/json/scanner.go
index 05218f9cc3..9dc1903e2d 100644
--- a/src/encoding/json/scanner.go
+++ b/src/encoding/json/scanner.go
@@ -49,12 +49,6 @@ type SyntaxError struct {
func (e *SyntaxError) Error() string { return e.msg }
-// Is returns true if target is a SyntaxError.
-func (e *SyntaxError) Is(target error) bool {
- _, ok := target.(*SyntaxError)
- return ok
-}
-
// A scanner is a JSON scanning state machine.
// Callers call scan.reset and then pass bytes in one at a time
// by calling scan.step(&scan, c) for each byte.
diff --git a/src/encoding/json/scanner_test.go b/src/encoding/json/scanner_test.go
index c12d9bf3d7..3737516a45 100644
--- a/src/encoding/json/scanner_test.go
+++ b/src/encoding/json/scanner_test.go
@@ -6,8 +6,6 @@ package json
import (
"bytes"
- "errors"
- "fmt"
"math"
"math/rand"
"reflect"
@@ -203,13 +201,6 @@ func TestIndentErrors(t *testing.T) {
}
}
-func TestSyntaxErrorIs(t *testing.T) {
- err := fmt.Errorf("apackage: %w: failed to parse struct", &SyntaxError{"some error", 43})
- if !errors.Is(err, &SyntaxError{}) {
- t.Fatalf("%v should be unwrapped to a SyntaxError", err)
- }
-}
-
func diff(t *testing.T, a, b []byte) {
for i := 0; ; i++ {
if i >= len(a) || i >= len(b) || a[i] != b[i] {