title: why is this a deadlock in golang / waitgroup?
body: <p>I'm not sure what I'm missing but I get a deadlock error.  I'm using a buffered channel that I range over after all go routines complete. The channel has the capacity of 4 and I'm running 4 go routines so I'm expecting it to be "closed" automatically once it reaches the max capacity.</p>
  
  <pre><code>package main
  
  import "fmt"
  import "sync"
  
  func main() {
      ch := make(chan []int, 4)
      var m []int
  
      var wg sync.WaitGroup
      for i := 0; i &lt; 5; i++ {
          wg.Add(1)
          go func() {
              defer wg.Done()
              ch &lt;- m
              return
          }()
      }
      wg.Wait()
  
      for c := range ch {
          fmt.Printf("c is %v", c)
      }
  }
  </code></pre>