go-multierror

A Go library for combining multiple error values into a single, introspectable error.

Library
Go
vv1.1.1
2,590 stars
Mozilla Public License 2.0

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
64 /100 Good
Development Activity 60
Maintenance 20
Community 76
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
66 /100 Good
Architecture 82
Code Quality 78
Innovation 40
Learning Curve 65

go-multierror is a small HashiCorp-maintained Go package that represents a list of error values as a single error. It lets a function accumulate several failures during a multi-step operation and return them all as one value, instead of stopping at the first error or requiring a custom error type. Callers that don’t know about multierror still get a readable, formatted error string; callers that do can type-assert to *multierror.Error and access the underlying Errors slice directly.

The package is fully compatible with the standard library errors package, implementing Unwrap, Is, and As so that errors.Is/errors.As traverse each wrapped error correctly. It also ships a Group type for coalescing errors from concurrent goroutines, plus Append, Flatten, and Prefix helpers for building and reshaping error lists. As of Go 1.20, the standard library’s errors.Join covers the basic aggregation case, and the README explicitly recommends it for new projects — go-multierror remains relevant where custom formatting, the Group pattern, or the existing Append/Flatten/Prefix API surface are needed.

What You Get

  • Append(err, errs...) — builds or extends a *multierror.Error from any error value, flattening nested multierrors one level
  • *multierror.Error implementing the standard error interface plus Unwrap/Is/As for errors package interop
  • Customizable ErrorFormat function to control how the combined error renders as a string
  • Group — a sync.WaitGroup-backed helper that coalesces errors returned by concurrent goroutines
  • Flatten and Prefix helpers for merging nested multierrors and annotating every wrapped error with a common prefix

Common Use Cases

  • Running several independent validation checks and reporting all failures in one response instead of stopping at the first
  • Fanning work out across goroutines with Group and collecting every failure once all of them finish
  • Aggregating per-resource errors in infrastructure tooling (e.g. Terraform providers, HashiCorp tooling) where one API call touches many resources
  • Wrapping a batch of cleanup or teardown steps so callers can see everything that went wrong, not just the last error

Under The Hood

Architecture

The package is a flat, single-package library with no internal boundaries: each file owns one orthogonal concern operating on the same *Error struct. multierror.go defines the core Error type (an Errors []error slice plus a pluggable ErrorFormat hook) along with its Error(), Unwrap(), GoString(), and WrappedErrors() methods, and a private chain type that makes errors.Is/errors.As traverse every wrapped error deterministically rather than only the first. append.go builds and flattens error lists one level deep, group.go layers a mutex-guarded sync.WaitGroup around Append for concurrent goroutine result collection, and format.go, flatten.go, prefix.go, and sort.go each add one composable utility. There is no dependency injection or external state; every function is a pure transformation of an error value, so the design surface is small and the core Error struct is the single point every other file depends on.

Tech Stack

go.mod declares Go 1.13 as the minimum version and an empty go.sum — the library has zero third-party dependencies, relying only on the standard library (errors, fmt, strings, sync). A Makefile wraps go test, and CI (.github/workflows/go-multierror.yml) runs a go fmt check plus the test suite on every push and pull request, with a separate actionlint.yml workflow linting the GitHub Actions files themselves. As a leaf library with no runtime dependencies, it’s consumed purely via go get with no deployment or database concerns of its own.

Code Quality

Every source file has a matching _test.go counterpart (covering Error, Append, Group, ListFormatFunc, Flatten, Prefix, and sort.Interface), written with the standard testing package and reflect.DeepEqual/t.Fatalf assertions rather than a third-party assertion library. Error handling is idiomatic Go — values are returned directly, and the core type explicitly implements Unwrap/Is/As so failures stay introspectable instead of being collapsed into strings. Naming is short and consistent (Append, Flatten, Prefix, Group), and CI enforces go fmt plus the full test suite, though there is no additional static-analysis linter (e.g. golangci-lint) configured beyond formatting.

What Makes It Unique

go-multierror doesn’t introduce a novel error-handling model — it’s a straightforward “slice of errors wrapped in one error” pattern, and the README itself now points new projects at the standard library’s errors.Join (Go 1.20+) for the basic aggregation case, including a migration guide. What it still offers beyond stdlib is narrower but genuine: the Group helper for concurrent error collection (deliberately absent from errgroup, which returns only the first error), a configurable ErrorFormat for custom rendering, and Flatten/Prefix utilities with no direct standard-library equivalent.

Used by 15 apps in this directory

Go
81%
GPL 3.0

Navidrome

File Storage · Music Audio

24,331

Run your own personal Spotify — stream your entire music collection from any device, anywhere, forever.

View details
91
Repo Health
81
Technical
66
Dependency
Built with
Go 81%
JavaScript 15%
Updated 1 weeks ago
Go
95%
Other

NetBird

Security

30,175

Replace your VPN with a zero-trust WireGuard overlay network that auto-connects devices, enforces SSO and posture checks, and deploys in under 5 minutes.

View details
92
Repo Health
82
Technical
66
Dependency
Built with
Go 95%
Updated 6 days ago
Go
99%
Apache 2.0

Okteto

Developer Tools · Devops

3,554

Develop applications directly inside your Kubernetes cluster with real-time file sync and instant hot-reload — no more docker build/redeploy cycles.

View details
91
Repo Health
79
Technical
69
Dependency
Built with
Go 99%
Updated 1 weeks ago
Go
98%
Other

Tyk API Gateway

Developer Tools · Devops

10,869

Cloud-native, high-performance open-source API gateway for REST, GraphQL, gRPC, and TCP — built in Go since 2014 with no feature lockout.

View details
97
Repo Health
78
Technical
67
Dependency
Built with
Go 98%
Updated 1 weeks ago
Go
97%
BSD 3

Weaviate

Databases · Search

16,908

Open-source vector database combining semantic search, hybrid queries, RAG, and image search in a single cloud-native system built for production scale.

View details
91
Repo Health
85
Technical
68
Dependency
Built with
Go 97%
Updated 1 weeks ago
Go
66%
AGPL 3.0

WriteFreely

Blogging · Social Media

5,275

A clean, Markdown-based publishing platform for writers, with built-in ActivityPub federation for connecting to the wider fediverse.

View details
86
Repo Health
63
Technical
69
Dependency
Built with
Go 66%
Go Template 23%
Updated 4 weeks ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers