Errgroup.Group
errgroup.Group is a Go type that coordinates concurrent functions, waits for them to finish, and records the first non-nil error.
Learn Go with Pocket-Sized Projects
errgroup.Group is a Go synchronization type that coordinates goroutines and reports an error from a failed goroutine.
- How it is used
- Coordinates concurrent goroutines when at least one goroutine’s error needs handling.
- How deep it goes
- Explains group creation, concurrency limits, goroutine registration, waiting, and returned errors through a runnable example.
- Examples
- Uses concurrent rice and curry preparation, including a task that may return an error.
- What you can do after
- Apply it via golang.org/x/sync/errgroup to limit parallel work and handle a goroutine error at a synchronization point.
Read how Learn Go with Pocket-Sized Projects explains errgroup.Group →
100 Go Mistakes and How to Avoid Them
errgroup.Group is a type that coordinates a group of goroutines and records the first non-nil error returned by them.
- How it is used
- Coordinates parallel calls while propagating the first error and sharing cancellation through context.
- How deep it goes
- Defines WithContext, Go, and Wait and demonstrates an indexed results handler, without detailing package internals.
- Examples
- Uses parallel foo calls over circles, an indexed results slice, and a corrected errgroup handler.
- What you can do after
- Build it from scratch using WithContext, Go, and Wait to collect results and return the first error.
Read how 100 Go Mistakes and How to Avoid Them explains errgroup.Group →
Related concepts
- WaitGroupcontrasts with · WaitGroup is a synchronization type that counts concurrent operations and allows execution to wait until the counter reaches zero.
- errgroup.Group.Gohas part · errgroup.Group.Go is a method that starts an error-returning function in a goroutine managed by an errgroup.Group and records its returned error.
- errgroup.Group.Waithas part · errgroup.Group.Wait is a method that blocks until all functions in an errgroup.Group finish and returns the first non-nil error.
- synchronizationuses · Synchronization coordinates operations, events, clocks, data, or states to establish required timing, ordering, visibility, or consistency relationships.
- errgrouppart of · errgroup is a Go package that coordinates concurrent functions or goroutines, propagates their errors, and can integrate cancellation through a context.
- error handlinguses · Error handling is the practice of detecting, representing, propagating, reporting, and responding to errors or failures during software operation.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

