func (s *streamReader) Read(p []byte) (n int, err error) {
	s.stream.cond.L.Lock()
	defer s.stream.cond.L.Unlock()
	n, err = s.reader.Read(p)

	// No errors, base case, return data
	if err == nil {
		return
	}

	// End of file reached
	for err == io.EOF {
		// If we are done writing, handle this as a normal case
		if s.stream.closed {
			return
		}
		// If partial data, return that data, mask the EOF since the writer may
		// write additional data in the future
		if n > 0 {
			return n, nil
		}
		// Else, no data was read, wait until more data is available
		s.stream.cond.Wait()
		n, err = s.reader.Read(p)
	}
	return
}
// Read reads data from the stream. If no data is currently available and the
// stream has not closed, the read method will block until more data is
// available. Only when the writer has declared no more data (closed = true)
// will the reader receive EOF.
Read reads data from the stream. If no data is currently available and the
stream has not closed, the read method will block until more data is
available. Only when the writer has declared no more data (closed = true)
will the reader receive EOF.
// Read reads data from the stream . If no data is currently available and the // stream has not closed the read method will block until more data is // available . Only when the writer has declared no more data ( closed = true ) // will the reader receive EOF .
func (s *streamReader) Read(p []byte) (n int, err error) {
	s.stream.cond.L.Lock()
	defer s.stream.cond.L.Unlock()
	n, err = s.reader.Read(p)
	if err == nil {
		return
	}
	for err == io.EOF {
		if s.stream.closed {
			return
		}
		if n > 0 {
			return n, nil
		}
		s.stream.cond.Wait()
		n, err = s.reader.Read(p)
	}
	return
}
func ( s * streamReader ) Read ( p [ ] byte ) ( n int , err error ) { s . stream . cond . L . Lock ( ) defer s . stream . cond . L . Unlock ( ) n , err = s . reader . Read ( p ) if err == nil { return } for err == io . EOF { if s . stream . closed { return } if n > 0 { return n , nil } s . stream . cond . Wait ( ) n , err = s . reader . Read ( p ) } return }
Read reads data from the stream.
Read reads data from the stream .
// No errors, base case, return data // End of file reached // If we are done writing, handle this as a normal case // If partial data, return that data, mask the EOF since the writer may // write additional data in the future // Else, no data was read, wait until more data is available