# multierr **Repository Path**: mirrors_andreyvit/multierr ## Basic Information - **Project Name**: multierr - **Description**: Merges multiple errors into a single error value in idiomatic Go way - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-04-06 - **Last Updated**: 2026-11-21 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # multierr [![Go Reference](https://pkg.go.dev/badge/github.com/andreyvit/multierr.svg)](https://pkg.go.dev/github.com/andreyvit/multierr) Provides an idiomatic Append function for errors, allowing to combine multiple errors into one. Install with `go get github.com/andreyvit/multierr`. Unlike `errors.Join`, `Append` returns the original error unchanged when only one non-nil error remains, preserving its concrete type. Multiple errors use numbered formatting and support `errors.Is` and `errors.As`. Complete example: ```go package main import ( "errors" "fmt" "github.com/andreyvit/multierr" ) func main() { var err error err = multierr.Append(err, errors.New("some failure")) err = multierr.Append(err, errors.New("another failure")) fmt.Println(err) } ``` For incremental accumulation: ```go err = multierr.Append(err, someFuncThatFails()) err = multierr.Append(err, anotherFuncThatFails()) ``` Printing the error results in something like: ```text 2 errors occurred: (1) some failure (2) another failure ``` Among other cases, this is especially useful in failable deferred funcs to avoid silently ignoring cleanup errors: ```go func sprinkleMagicDust() (err error) { d := &Dummy{} defer func() { err = multierr.Append(err, d.Close()) }() return d.DoSomeMagic() } ``` Unlike other overly complicated multierror packages, this one does not even expose its multierror type, and will only use it when you actually end up with more than a single error to return. The returned multierror type supports errors.Is and errors.As by delegating to each of the suberrors it contains. ## License © 2020-2021, Andrey Tarantsov. Published under the MIT License.