containers / image

Work with containers' images
Apache License 2.0
844 stars 366 forks source link

Add a helper for formatting multiple errors #2365

Closed mtrmac closed 3 months ago

mtrmac commented 3 months ago

As of Go 1.20, the standard library supposedly contains infrastructure for reporting multiple errors.

Sadly, that infrastructure is mostly unhelpful: errors.Join gives no control over formatting, and fmt.Errorf does not support a []error input. So, introduce our own multierr.Format, and use it where possible.

Then remove the go-multierror dependency. The net result is not particularly better code, but at least we try to work with the standard library design.

(This was originally motivated just by trying to remove the go-multierror dependency in #2364, now that the standard library supposedly supports the feature.)

This might, in some cases, change whether the returned error matches errors.{As,Is}, mostly because the previous code for aggregating multiple errors was written before Go 1.20 made it possible for multiple errors to match. (Not that I know how the multi-matching design can ever be all that useful…)

See individual commit messages for details.

rhatdan commented 3 months ago

LGTM @giuseppe PTAL