Interview practice question
Fan-out with early cancellation
Backend Engineering · Concurrency · Experienced
Your Go handler fans out to 10 services concurrently. If any call fails, you want to cancel the rest and return an error quickly. How do you implement it?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- errgroup.WithContext.
- Each goroutine uses ctx.
- First error cancels context.
- g.Wait returns first error.
- Calls must respect ctx cancellation.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.