title: Passing a slice into a channel
body: <p>I'm trying to pass the results of munging a slice into a channel. Here's the obviously broken version. I've tried a few ways of doing it that don't seem to work well. I'm looking for an idiomatic way of tackling this.</p>
  
  <pre><code>func gen() &lt;-chan []int {
      c := make(chan []int)
  
      go func(c chan []int) {
          defer close(c)
          s := []int{0, 1, 2, 3}
  
          for i := 0; i &lt; len(s); i++ {
              s[i] = -1
              c &lt;- s
          }
      }(c)
  
      return c
  
  }
  
  func main() {
      for s := range gen() {
          fmt.Println(s)
      }
  }
  </code></pre>
  
  <p>Result:</p>
  
  <pre><code>[-1 -1 2 3]
  [-1 -1 2 3]
  [-1 -1 -1 -1]
  [-1 -1 -1 -1]
  </code></pre>