multierror

package module
v0.0.0-...-11879ef Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 3 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package multierror aggregates a list of errors into a single error value that satisfies the error interface.

This is a yoke clean-room implementation written for S488.3c (remove the MPL-2.0 hashicorp/go-multierror dependency from the engine build). It was written from the call sites and expectations of its permissive callers (podman pkg/errorhandling, pkg/bindings/images, pkg/machine/shim and containers/common retry/supplemented/libimage) without reading the replaced module's source. Only the public API those callers use is provided: the Error type with its Errors field, Append, ErrorOrNil, Len, and the Error and Unwrap methods, plus Group for the Linux buildah caller.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Error

type Error struct {
	// Errors holds the aggregated errors in append order. Callers may
	// read the slice (the containers/common retry package type-switches
	// on *Error and iterates it) but should extend it only via Append.
	Errors []error
}

Error is an aggregate of zero or more errors. The zero value is not useful; grow one with Append, starting from a nil *Error.

func Append

func Append(err error, errs ...error) *Error

Append returns a new aggregate with errs appended to err, or err itself when err is already a non-empty *Error.

A nil err (including a typed-nil *Error, the idiom used by the podman callers) starts a fresh aggregate. Nil elements in errs are skipped, and an element that is itself a *Error is flattened into its constituent errors. When the result would hold no errors, Append returns nil, so callers testing the result against nil — directly or through an error interface — see nil.

func (*Error) Error

func (e *Error) Error() string

Error renders the aggregate as a header line naming the error count followed by one tab-indented bullet per error, ending with a blank line:

2 errors occurred:
	* first failure
	* second failure

The podman errorhandling package documents this header-plus-list shape (and trims the trailing blank line itself).

func (*Error) ErrorOrNil

func (e *Error) ErrorOrNil() error

ErrorOrNil returns the aggregate as an error interface value, or nil when no errors were appended. It is safe to call on a nil *Error.

func (*Error) Len

func (e *Error) Len() int

Len reports how many errors the aggregate holds; 0 on a nil *Error.

func (*Error) Unwrap

func (e *Error) Unwrap() []error

Unwrap exposes the aggregated errors to errors.Is and errors.As, following the standard multi-error unwrapping convention.

type Group

type Group struct {
	// contains filtered or unexported fields
}

Group runs functions concurrently and aggregates their errors, written for the buildah imagebuildah caller (S488.3e Linux engine graph): a zero-value Group, Go per task, then one Wait.

func (*Group) Go

func (g *Group) Go(f func() error)

Go runs f in a new goroutine, recording a non-nil error it returns.

func (*Group) Wait

func (g *Group) Wait() *Error

Wait blocks until every function started with Go has returned and yields their errors, or nil when none failed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL