Menu

1 / 2

errgroup vs WaitGroup vs Channels: Pick the Right Concurrency Primitive

DEV Community·Gabriel Anhaia·6 months ago
#zVlKAzBI
#case#go#concurrency#error#errgroup
Reading 0:00
15s threshold

Book: The Complete Guide to Go Programming

Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go

My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools

Me: xgabriel.com | GitHub

A backend engineer I worked with had a translation pipeline.

A thousand documents go in, a thousand translated documents come

out. The first version used errgroup.WithContext because that is

what every Go talk on YouTube reaches for. One document failed to

translate because the upstream API rate-limited that single tenant.

The context cancelled. 999 documents that were already translated

got thrown away, and the retry job ran the whole batch again. The

cloud bill went up.

The bug was not in the code. The code did exactly what errgroup

documents. The bug was that someone picked errgroup for a job

where you want to collect everything, not fail-fast on the first

error.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.