typeover
curriculum

Curriculum Idioms & ecosystem Context exercise 2 · mcq

Context

Pick the line that creates a CANCELLABLE child context from a parent ctx. The result should be a pair: the child context AND a function the caller invokes to cancel it. TypeScript: const ctrl = new AbortController() returns a controller; you read .signal and call .abort(). Go's shape is similar but returns the context + cancel function as a pair.

TypeScript reference
Pick the idiomatic Go translation

About this theme

context.Context propagates cancellation, deadlines, and request-scoped values across goroutines and API boundaries. By convention, the first argument of any function that does I/O or starts a goroutine is ctx context.Context. Listening for <-ctx.Done() is how you write cancellable work.