https://gobyexample.com/range-over-channels #108

Open
andradei opened this Issue Jun 27, 2015 · 0 comments

1 participant

@andradei

Thank you for putting Go by Example online. It has helped me a lot on my journey to learn Golang.

The 3rd paragraph on Range Over Channels states

If we didn’t close it we’d block on a 3rd receive in the loop.

But if we take close(queue) out of the example, an error is created on the 3rd iteration.
Here is the result:

one
two
fatal error: all goroutines are asleep - deadlock!

goroutine 1 [chan receive]:
main.main()
    /tmp/sandbox354051104/main.go:22 +0x120
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment