diff --git a/internal/errors/errors_test.go b/internal/errors/errors_test.go index 804eb96c2..d03b9920f 100644 --- a/internal/errors/errors_test.go +++ b/internal/errors/errors_test.go @@ -50,16 +50,16 @@ func TestErrors(t *testing.T) { if got, want := test.err.Error(), prefix+test.wantText; got != want { t.Errorf("%v.Error() = %q, want %q", test.what, got, want) } - if got, want := Is(test.err, Error), true; got != want { + if got, want := errors.Is(test.err, Error), true; got != want { t.Errorf("errors.Is(%v, errors.Error) = %v, want %v", test.what, got, want) } for _, err := range test.is { - if got, want := Is(test.err, err), true; got != want { + if got, want := errors.Is(test.err, err), true; got != want { t.Errorf("errors.Is(%v, %v) = %v, want %v", test.what, err, got, want) } } for _, err := range test.isNot { - if got, want := Is(test.err, err), false; got != want { + if got, want := errors.Is(test.err, err), false; got != want { t.Errorf("errors.Is(%v, %v) = %v, want %v", test.what, err, got, want) } } diff --git a/internal/errors/is_go112.go b/internal/errors/is_go112.go deleted file mode 100644 index fbcd34920..000000000 --- a/internal/errors/is_go112.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !go1.13 -// +build !go1.13 - -package errors - -import "reflect" - -// Is is a copy of Go 1.13's errors.Is for use with older Go versions. -func Is(err, target error) bool { - if target == nil { - return err == target - } - - isComparable := reflect.TypeOf(target).Comparable() - for { - if isComparable && err == target { - return true - } - if x, ok := err.(interface{ Is(error) bool }); ok && x.Is(target) { - return true - } - if err = unwrap(err); err == nil { - return false - } - } -} - -func unwrap(err error) error { - u, ok := err.(interface { - Unwrap() error - }) - if !ok { - return nil - } - return u.Unwrap() -} diff --git a/internal/errors/is_go113.go b/internal/errors/is_go113.go deleted file mode 100644 index 5e72f1cde..000000000 --- a/internal/errors/is_go113.go +++ /dev/null @@ -1,13 +0,0 @@ -// Copyright 2020 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.13 -// +build go1.13 - -package errors - -import "errors" - -// Is is errors.Is. -func Is(err, target error) bool { return errors.Is(err, target) } diff --git a/proto/decode_test.go b/proto/decode_test.go index c0a15e2b4..ba83942a3 100644 --- a/proto/decode_test.go +++ b/proto/decode_test.go @@ -6,6 +6,7 @@ package proto_test import ( "bytes" + "errors" "fmt" "reflect" "testing" @@ -16,7 +17,6 @@ import ( "google.golang.org/protobuf/testing/protopack" "google.golang.org/protobuf/types/known/durationpb" - "google.golang.org/protobuf/internal/errors" testpb "google.golang.org/protobuf/internal/testprotos/test" test3pb "google.golang.org/protobuf/internal/testprotos/test3" ) diff --git a/proto/encode_test.go b/proto/encode_test.go index 73b3b1817..947953f08 100644 --- a/proto/encode_test.go +++ b/proto/encode_test.go @@ -6,6 +6,7 @@ package proto_test import ( "bytes" + "errors" "fmt" "math" "reflect" @@ -19,7 +20,6 @@ import ( "google.golang.org/protobuf/reflect/protoreflect" "google.golang.org/protobuf/types/known/durationpb" - "google.golang.org/protobuf/internal/errors" orderpb "google.golang.org/protobuf/internal/testprotos/order" testpb "google.golang.org/protobuf/internal/testprotos/test" test3pb "google.golang.org/protobuf/internal/testprotos/test3"