title: Multiple goroutines listening on one channel
body: <p>I have multiple goroutines trying to receive on the same channel simultaneously. It seems like the last goroutine that starts receiving on the channel gets the value. Is this somewhere in the language spec or is it undefined behaviour?</p>
  <pre><code>c := make(chan string)
  for i := 0; i &lt; 5; i++ {
      go func(i int) {
          &lt;-c
          c &lt;- fmt.Sprintf(&quot;goroutine %d&quot;, i)
      }(i)
  }
  c &lt;- &quot;hi&quot;
  fmt.Println(&lt;-c)
  </code></pre>
  <p>Output:</p>
  <pre><code>goroutine 4
  </code></pre>
  <p><a href="http://play.golang.org/p/7TuA7kLtks" rel="noreferrer">Example On Playground</a></p>
  <p><strong>EDIT:</strong></p>
  <p>I just realized that it's more complicated than I thought. The message gets passed around all the goroutines.</p>
  <pre><code>c := make(chan string)
  for i := 0; i &lt; 5; i++ {
      go func(i int) {
          msg := &lt;-c
          c &lt;- fmt.Sprintf(&quot;%s, hi from %d&quot;, msg, i)
      }(i)
  }
  c &lt;- &quot;original&quot;
  fmt.Println(&lt;-c)
  </code></pre>
  <p>Output:</p>
  <pre><code>original, hi from 0, hi from 1, hi from 2, hi from 3, hi from 4
  </code></pre>
  <p><strong>NOTE:</strong> <em>the above output is outdated in more recent versions of Go (see comments)</em></p>
  <p><a href="http://play.golang.org/p/3y-YQG8dAb" rel="noreferrer">Example On Playground</a></p>