tezvyn:

Cancellation and cleanup: Go context/errgroup vs Tokio

Source: interviewintermediate

WHAT IT TESTS: structured-concurrency cancellation knowledge. OUTLINE: Go propagates cancellation via context.Context that goroutines must poll, with errgroup canceling siblings on first error; Tokio cancels by dropping futures, which stops them at await…

WHAT IT TESTS: whether you understand cooperative cancellation and cleanup guarantees in both ecosystems. ANSWER OUTLINE: Go uses context.Context: cancellation is cooperative, signaled via a Done channel that goroutines must check; errgroup runs a group of goroutines, cancels the shared context on the first error, and Wait returns that error. Cleanup relies on defer and on goroutines observing Done. Tokio cancels a future by dropping it (e.g. select!

Read the original → interview

Get five bites like this every day.

Tezvyn delivers a daily feed of 60-second tech bites with quizzes to lock in what you learn.

Cancellation and cleanup: Go context/errgroup vs Tokio · Tezvyn