aboutsummaryrefslogtreecommitdiff
path: root/src/errors
diff options
context:
space:
mode:
Diffstat (limited to 'src/errors')
-rw-r--r--src/errors/wrap.go4
-rw-r--r--src/errors/wrap_test.go8
2 files changed, 6 insertions, 6 deletions
diff --git a/src/errors/wrap.go b/src/errors/wrap.go
index ab3cdb86d3..263ae16b48 100644
--- a/src/errors/wrap.go
+++ b/src/errors/wrap.go
@@ -75,7 +75,7 @@ func Is(err, target error) bool {
//
// As panics if target is not a non-nil pointer to either a type that implements
// error, or to any interface type.
-func As(err error, target interface{}) bool {
+func As(err error, target any) bool {
if target == nil {
panic("errors: target cannot be nil")
}
@@ -93,7 +93,7 @@ func As(err error, target interface{}) bool {
val.Elem().Set(reflectlite.ValueOf(err))
return true
}
- if x, ok := err.(interface{ As(interface{}) bool }); ok && x.As(target) {
+ if x, ok := err.(interface{ As(any) bool }); ok && x.As(target) {
return true
}
err = Unwrap(err)
diff --git a/src/errors/wrap_test.go b/src/errors/wrap_test.go
index a22fee2f04..eb8314b04b 100644
--- a/src/errors/wrap_test.go
+++ b/src/errors/wrap_test.go
@@ -66,7 +66,7 @@ var poserPathErr = &fs.PathError{Op: "poser"}
func (p *poser) Error() string { return p.msg }
func (p *poser) Is(err error) bool { return p.f(err) }
-func (p *poser) As(err interface{}) bool {
+func (p *poser) As(err any) bool {
switch x := err.(type) {
case **poser:
*x = p
@@ -90,9 +90,9 @@ func TestAs(t *testing.T) {
testCases := []struct {
err error
- target interface{}
+ target any
match bool
- want interface{} // value of target on match
+ want any // value of target on match
}{{
nil,
&errP,
@@ -171,7 +171,7 @@ func TestAs(t *testing.T) {
func TestAsValidation(t *testing.T) {
var s string
- testCases := []interface{}{
+ testCases := []any{
nil,
(*int)(nil),
"error",