Skip to content
CodeWiki
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
Search
⌘K
English
English
Chinese
Practice
Paths
Tracks
Cheatsheets
Playground
Glossary
AI era
English
English
Chinese
Practice
/
Quiz
/
Go
/
Go
Which worker-loop design responds promptly when its request is cancelled?
from Go
advanced
1 min
Which worker-loop design responds promptly when its request is cancelled?
Select between the work operation and `<-ctx.Done()`, returning `ctx.Err()` on cancellation.
Store the context in a global variable and poll it only after all work completes.
Replace the context with `time.Sleep` so the worker eventually wakes up.
Check
Ask AI about this kata
Report an error
previous kata
A function calls `context.WithTimeout`. Name the returned function it must call to releas…
Fill in
next kata
In `value, ok := <-ch`, which result becomes false after a closed channel has been draine…
Fill in
A new version is available
Reload