3 ms·
Context with wait support in Go
- mgsouth 6y agoThere's a race condition in Done() between ctx.Value() and close(); two goroutines simultaneously calling Done() can both see Value() ok, then second one calling close() will panic. Mixing multiple concurrency coordinators (in this case a context and a channel) is tricky, and Go adds little gotchas to the mix. You need a mutex to make all operations atomic across both the context and channel.
- captplanet 6y agoGood spot!