title: Why does the use of an unbuffered channel in the same goroutine result in a deadlock?
body: <p>I'm sure that there is a simple explanation to this trivial situation, but I'm new to the <code>go</code> concurrency model.</p>
  
  <p>when I run this example</p>
  
  <pre><code>package main
  
  import "fmt"
  
  func main() {
      c := make(chan int)    
      c &lt;- 1   
      fmt.Println(&lt;-c)
  }
  </code></pre>
  
  <p>I get this error :</p>
  
  <pre><code>fatal error: all goroutines are asleep - deadlock!
  
  goroutine 1 [chan send]:
  main.main()
      /home/tarrsalah/src/go/src/github.com/tarrsalah/tour.golang.org/65.go:8 +0x52
  exit status 2
  </code></pre>
  
  <p>Why ?</p>
  
  <hr>
  
  <p>Wrapping <code>c &lt;-</code> in a <code>goroutine</code> makes the example run as we expected </p>
  
  <pre><code>package main
  
  import "fmt"
  
  func main() {
      c := make(chan int)        
      go func(){
         c &lt;- 1
      }()
      fmt.Println(&lt;-c)
  }
  </code></pre>
  
  <p>Again, why ?</p>
  
  <p>Please, I need deep explanation , not just how to eliminate the deadlock and fix the code. </p>