Unless a channel is buffered, it is synchronous. A send cannot take place until the reader is ready to receive.
You can make it buffered using numCh = make(chan int, 1) go write() go read() Or you can have two calls to read(): numCh = make(chan int) go write() go read() go read() On Wednesday, 27 July 2022 at 08:13:34 UTC+1 aravind...@gmail.com wrote: > Hi All, > When I was explaining basics of channels to newcomers, I was using the > below example > https://go.dev/play/p/xx2qqU2qqyp > > I was expecting both Write 5 and Write 3 to be printed. But only Write 5 > was printed. I couldn't reason out the behaviour, can somebody point out > what I am assuming wrong about. > > Thanks, > Aravindhan K > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/a831b7a2-95fe-4a65-ab75-7d361ce4d577n%40googlegroups.com.