Re: [go-nuts] Two consecutive reads from a buffered channel results in deadlock

2021-09-04 Thread Michael Dwyer
Kurtis, thank you for your explanation and for the links, providing more detailed information on the subject matter. This was what I was looking for, a reasoned explanation and documentation that would explain why this condition occurred. Always good when there are those willing to provide helpf

Re: [go-nuts] Two consecutive reads from a buffered channel results in deadlock

2021-09-04 Thread 'Dan Kortschak' via golang-nuts
What would you expect to happen here? A chan that has had one item sent and then one item received has no items on it, so a receive must wait until another item is sent. On Sat, 2021-09-04 at 17:55 -0700, Michael Dwyer wrote: > I encountered a deadlock when reading from a buffered channel. > The d

Re: [go-nuts] Two consecutive reads from a buffered channel results in deadlock

2021-09-04 Thread Kurtis Rader
On Sat, Sep 4, 2021 at 5:55 PM Michael Dwyer wrote: > I encountered a deadlock when reading from a buffered channel. > The deadlock occurs when an attempt is made to read from the channel > twice, without an intermediate write to the channel. > That is not a deadlock. Reading from a buffered cha

[go-nuts] Two consecutive reads from a buffered channel results in deadlock

2021-09-04 Thread Michael Dwyer
I encountered a deadlock when reading from a buffered channel. The deadlock occurs when an attempt is made to read from the channel twice, without an intermediate write to the channel. The problematic code is as follows: func main() { myInt := 432 readerChan := make(chan int, 3) for forI