title: Read until end of channel in Go
body: <p>The producer fills up the channel with some values and closes it.
  On the consumer side I want to add up all the values and leave the loop at the end.  My solution looks like:</p>
  
  <pre><code>total := 0
  for {
      v, ok := &lt;- ch
      if !ok { break }
      total += v
  }
  </code></pre>
  
  <p>Is there any more elegant way?</p>