title: Number of elements in a channel
body: <p>Using a buffered channel, how do measure how many elements are in the channel? For example, I'm creating and sending on a channel like this:</p>
  
  <pre><code>send_ch := make(chan []byte, 100)
  // code
  send_ch &lt;- msg
  </code></pre>
  
  <p>I want to measure how many <strong>msgs</strong> are in the channel <strong>send_ch</strong>.</p>
  
  <p>I'm aware that due to concurrency the measurement won't be exact, as pre-emption could occur between measurement and action (eg discussed in this video <a href="http://www.youtube.com/watch?v=f6kdp27TYZs" rel="noreferrer">Google I/O 2012 - Go Concurrency Patterns</a>). I'll be using this for flow control between producers and consumers ie once I've passed through a high watermark, changing some behaviour until I pass back through a low watermark.</p>