Sameer is correct, but to be clear - The *block* happens because the 
channel is empty, so the receive operation blocks forever. This happens in 
both of the cases you show.

The *deadlock* happens because *all* goroutines are blocked and none can 
continue. So if you start some other goroutine that is not blocked, you 
won't have a deadlock, even though your main routine is blocked forever, 
which you are inadvertently doing by that import. Or, more to the point, 
you have a deadlock that Go can't detect as such - because technically, 
there is a goroutine running that could at some point read from that 
channel and your main routine would be unblocked and continue. It won't, 
because it has no reference to it, but the compiler is not currently able 
to detect that.

Again, both cases actually block. It is merely that in the first case the 
compiler can detect that it is a 'forever-blocked' situation and kills the 
program with a warning that it was deadlocked.

Howard

-- 
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.

Reply via email to