internal/errors: delete compatibility code for Go before 1.13
Currently, Go Protobuf requires Go 1.21.
Change-Id: I0b923f4f7732d54628f84e93adccc12f74f14e8e
Reviewed-on: https://go-review.googlesource.com/c/protobuf/+/637475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Chressie Himpel <chressie@google.com>
Auto-Submit: Michael Stapelberg <stapelberg@google.com>
diff --git a/internal/errors/errors_test.go b/internal/errors/errors_test.go
index 804eb96..d03b992 100644
--- a/internal/errors/errors_test.go
+++ b/internal/errors/errors_test.go
@@ -50,16 +50,16 @@
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 fbcd349..0000000
--- 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 5e72f1c..0000000
--- 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 c0a15e2..ba83942 100644
--- a/proto/decode_test.go
+++ b/proto/decode_test.go
@@ -6,6 +6,7 @@
import (
"bytes"
+ "errors"
"fmt"
"reflect"
"testing"
@@ -16,7 +17,6 @@
"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 73b3b18..947953f 100644
--- a/proto/encode_test.go
+++ b/proto/encode_test.go
@@ -6,6 +6,7 @@
import (
"bytes"
+ "errors"
"fmt"
"math"
"reflect"
@@ -19,7 +20,6 @@
"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"