title: go routines deadlocked even if channel was closed
body: <p>I have a list, with a function that pop element from it, and another function that "receives" the popped elements. I thought that putting a close after the receiver would close the channel, but it seems that the program is deadlock before getting there. Which is the best way of doing this? Should I have another channel that detects when the pop are done?</p>
  
  <p><a href="http://play.golang.org/p/vaoi-02F6e" rel="nofollow">Playground link</a></p>
  
  <pre><code>func pop(list *[]int, c chan int) {
      if len(*list) != 0 {
          result := (*list)[0]
          *list = (*list)[1:]
          fmt.Println("about to send ", result)
          c &lt;- result
      } else {
          return
      }
  }
  
  func receiver(c chan int) {
  
      result := &lt;-c
      fmt.Println("received ", result)
  }
  
  var list = []int{1, 2, 3}
  
  func main() {
  
      fmt.Println("Main")
      c := make(chan int)
      go pop(&amp;list, c)
      go pop(&amp;list, c)
      for len(list) &gt; 0 {
          receiver(c)
      }
      close(c) //Dosen't seem to have any effect
      fmt.Println("done")
  
  }
  </code></pre>