Golang Channel Deadlock
The number of channels is limited and whenever we try to receive or send value from and to the channel out of number, a deadlock occurs.
1. Receiving channels more than expected
go func(ch <-chan int) { i := <-ch j := <-ch fmt.Println("Value of Channel i,j =", i, j) wg.Done() }(ch)Error:- fatal error: all goroutines are asleep – deadlock!
Here, there is only a single channel from where data is sent, and two receiving channels and thus Deadlock occurs.
Read Full Post onGolang Channel Deadlock.
Top comments(0)
Subscribe
For further actions, you may consider blocking this person and/orreporting abuse