code: func (b *buffer) Read(buf []byte) (n int, err error) {
  	b.Cond.L.Lock()
  	defer b.Cond.L.Unlock()
  
  	for len(buf) > 0 {
  		// if there is data in b.head, copy it
  		if len(b.head.buf) > 0 {
  			r := copy(buf, b.head.buf)
  			buf, b.head.buf = buf[r:], b.head.buf[r:]
  			n += r
  			continue
  		}
  		// if there is a next buffer, make it the head
  		if len(b.head.buf) == 0 && b.head != b.tail {
  			b.head = b.head.next
  			continue
  		}
  
  		// if at least one byte has been copied, return
  		if n > 0 {
  			break
  		}
  
  		// if nothing was read, and there is nothing outstanding
  		// check to see if the buffer is closed.
  		if b.closed {
  			err = io.EOF
  			break
  		}
  		// out of buffers, wait for producer
  		b.Cond.Wait()
  	}
  	return
  }
docs: // Read reads data from the internal buffer in buf.  Reads will block
  // if no data is available, or until the buffer is closed.