Learning paths / Go concurrency interview questions
Go concurrency interview questions
Ten questions interviewers ask about goroutines, channels, locks and leaks. Guess, then watch the answer run.
- Two goroutines both run count++. Why can the total come out wrong?Go · BasicsWhy count++ loses updates in goroutines
- Does a send on an unbuffered channel wait for the receiver?Go · BasicsDoes a channel send wait for the receiver?
- Why can main return before your goroutines have run?Go · BasicsWhy didn't my goroutines run?
- When does Go stop with "all goroutines are asleep", and when does it just hang?Go · Basicsfatal error: all goroutines are asleep - deadlock! Why Go stops the program
- How do you put a timeout on a channel receive, and what can it leak?Go · IntermediateA select timeout that leaks a goroutine
- How does cancelling a context stop a goroutine, and what if the goroutine ignores it?Go · IntermediateStopping goroutines with context cancellation
- What is a goroutine leak, and how do you fix one?Go · IntermediateGoroutine leak: a blocked send after ctx.Done()
- How do you build a worker pool, and why close the jobs channel?Go · IntermediateA worker pool on a channel
- When is an RWMutex better than a Mutex, and when do readers still wait?Go · Intermediatesync.RWMutex: many readers at once, one writer alone
- Is a Go map safe to write from two goroutines? What happens if you do?Go · Intermediatefatal error: concurrent map writes, explained