Errgroup
errgroup is a Go package that coordinates concurrent functions or goroutines, propagates their errors, and can integrate cancellation through a context.
Learn Go with Pocket-Sized Projects
errgroup is a Go package for synchronizing goroutines while collecting errors from their functions.
- How it is used
- Coordinates concurrent goroutines while replacing explicit error-channel handling with Group methods.
- How deep it goes
- Explains Group creation, Go, SetLimit, and Wait, but defers detailed context treatment.
- Examples
- Demonstrates concurrent cooking of rice and curry with a two-goroutine limit.
- What you can do after
- Operate golang.org/x/sync/errgroup to launch limited concurrent work and handle errors returned by Wait.
Read how Learn Go with Pocket-Sized Projects explains errgroup →
100 Go Mistakes and How to Avoid Them
errgroup is a Go package for coordinating groups of goroutines with synchronization, error propagation, and context cancellation.
- How it is used
- Coordinates parallel calls while propagating errors and handling cancellation through a context.
- How deep it goes
- Demonstrates installation, group creation, worker functions, indexed results, and g.Wait, without explaining package internals.
- Examples
- Uses a handler that splits input circles into parallel external calls and stores results in input order.
- What you can do after
- Apply it via golang.org/x/sync/errgroup to coordinate parallel Go work and return one encountered error.
Read how 100 Go Mistakes and How to Avoid Them explains errgroup →
Related concepts
- errgroup.Grouphas part · errgroup.Group is a Go type that coordinates concurrent functions, waits for them to finish, and records the first non-nil error.
- contextuses · In Go, context.Context is an interface carrying cancellation signals, deadlines, and request-scoped values across function and service boundaries.
- 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.

