Given the following simple Go program:
ch := make(chan int)
go fmt.Println(<- ch)
ch <- 2
If I replace go fmt.Println(<- ch)
with go func(){fmt.Println(<-ch)}()
, it works well.
But with the original version I get:
fatal error: all goroutines are asleep - deadlock!
Why?