title: Is it better to range over channel or use select?
body: <p>guys i was wondering if it is better to to range over channel or use select, if I have only one case (my channel) and signal the end with close of the given channel ?</p>
  
  <p>Given the examples:</p>
  
  <h3>1. <a href="https://play.golang.org/p/3ZFdbgHSKyN" rel="noreferrer">https://play.golang.org/p/3ZFdbgHSKyN</a></h3>
  
  <pre><code>go func() {
      for v := range ch {
          // do some stuff
      }
  }()
  </code></pre>
  
  <h3>2. <a href="https://play.golang.org/p/iCCkDge8j72" rel="noreferrer">https://play.golang.org/p/iCCkDge8j72</a></h3>
  
  <pre><code>go func() {
      for {
          select {
          case v, ok := &lt;-ch:
              if !ok {
                  return
              }
  
              // do some stuff
          }
      }
  }()
  </code></pre>
  
  <p>Which solution would be preferred and why ? Please consider the fact that goroutines as such might be spawned many times (many workers).</p>