Ver código fonte

util/multierr: implement Go 1.20+'s multiple error Unwrap

Now that Go 1.20 is released, multierr.Error can implement
Unwrap() []error

Updates #7123

Signed-off-by: Andrew Dunham <[email protected]>
Change-Id: Ic28c2579de6799801836c447afbca8cdcba732cf
Andrew Dunham 3 anos atrás
pai
commit
2dc3dc21a8
1 arquivos alterados com 1 adições e 11 exclusões
  1. 1 11
      util/multierr/multierr.go

+ 1 - 11
util/multierr/multierr.go

@@ -33,15 +33,12 @@ func (e Error) Errors() []error {
 	return slices.Clone(e.errs)
 }
 
-// TODO(https://go.dev/cl/53435): Implement Unwrap when Go 1.20 is released.
-/*
-// Unwrap returns the underlying errors as is.
+// Unwrap returns the underlying errors as-is.
 func (e Error) Unwrap() []error {
 	// Do not clone since Unwrap requires callers to not mutate the slice.
 	// See the documentation in the Go "errors" package.
 	return e.errs
 }
-*/
 
 // New returns an error composed from errs.
 // Some errors in errs get special treatment:
@@ -135,13 +132,6 @@ func Range(err error, fn func(error) bool) bool {
 				return false
 			}
 		}
-	// TODO(https://go.dev/cl/53435): Delete this when Error implements Unwrap.
-	case Error:
-		for _, err := range err.errs {
-			if !Range(err, fn) {
-				return false
-			}
-		}
 	}
 	return true
 }