Categorygo.uber.org/multierr
modulepackage
1.11.0
Repository: https://github.com/uber-go/multierr.git
Documentation: pkg.go.dev

# README

multierr GoDoc Build Status Coverage Status

multierr allows combining one or more Go errors together.

Features

  • Idiomatic: multierr follows best practices in Go, and keeps your code idiomatic.
    • It keeps the underlying error type hidden, allowing you to deal in error values exclusively.
    • It provides APIs to safely append into an error from a defer statement.
  • Performant: multierr is optimized for performance:
    • It avoids allocations where possible.
    • It utilizes slice resizing semantics to optimize common cases like appending into the same error object from a loop.
  • Interoperable: multierr interoperates with the Go standard library's error APIs seamlessly:
    • The errors.Is and errors.As functions just work.
  • Lightweight: multierr comes with virtually no dependencies.

Installation

go get -u go.uber.org/multierr@latest

Status

Stable: No breaking changes will be made before 2.0.


Released under the MIT License.

# Functions

Append appends the given errors together.
AppendFunc is a shorthand for [AppendInvoke].
AppendInto appends an error into the destination of an error pointer and returns whether the error being appended was non-nil.
AppendInvoke appends the result of calling the given Invoker into the provided error pointer.
Close builds an Invoker that closes the provided io.Closer.
Combine combines the passed errors into a single error.
Errors returns a slice containing zero or more errors that the supplied error is composed of.
Every compares every error in the given err against the given target error using [errors.Is], and returns true only if every comparison returned true.

# Interfaces

Invoker is an operation that may fail with an error.

# Type aliases

Invoke wraps a function which may fail with an error to match the Invoker interface.