It is as described in the spec. Regarding the specs it's correct. But that's not the reason.
The original question is about the "why". Why is that so? This behavior was unexpected. On Wednesday, January 24, 2018 at 11:20:01 PM UTC+3:30, Axel Wagner wrote: > > Both the channel and the value expression are evaluated before >> communication begins. Communication blocks until the send can proceed. A >> send on an unbuffered channel can proceed if a receiver is ready. A send on >> a buffered channel can proceed if there is room in the buffer. A send on a >> closed channel proceeds by causing a run-time panic. A send on a nil >> channel blocks forever. > > > https://golang.org/ref/spec#Send_statements > > So, yes. > > On Wed, Jan 24, 2018 at 8:43 PM, dc0d <kaveh.sh...@gmail.com <javascript:> > > wrote: > >> If the channel is nil, there's nothing to lock. But also, there's no >>> sending happening. >>> >> >> So first the payload is computed and then the nil check happens? >> >> -- >> 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...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/d/optout. >> > > -- 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. For more options, visit https://groups.google.com/d/optout.