From 2dc3dc21a8076e350cb1cee7e03d6e21aaa6f7a3 Mon Sep 17 00:00:00 2001 From: Andrew Dunham Date: Thu, 2 Feb 2023 12:53:24 -0500 Subject: [PATCH] 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 Change-Id: Ic28c2579de6799801836c447afbca8cdcba732cf --- util/multierr/multierr.go | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/util/multierr/multierr.go b/util/multierr/multierr.go index 5660e17c3..8f40e0111 100644 --- a/util/multierr/multierr.go +++ b/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 }