code: func (r *segmentBufReader) Read(b []byte) (n int, err error) {
  	n, err = r.buf.Read(b)
  	r.off += n
  
  	// If we succeeded, or hit a non-EOF, we can stop.
  	if err == nil || err != io.EOF {
  		return n, err
  	}
  
  	// We hit EOF; fake out zero padding at the end of short segments, so we
  	// don't increment curr too early and report the wrong segment as corrupt.
  	if r.off%pageSize != 0 {
  		i := 0
  		for ; n+i < len(b) && (r.off+i)%pageSize != 0; i++ {
  			b[n+i] = 0
  		}
  
  		// Return early, even if we didn't fill b.
  		r.off += i
  		return n + i, nil
  	}
  
  	// There is no more deta left in the curr segment and there are no more
  	// segments left.  Return EOF.
  	if r.cur+1 >= len(r.segs) {
  		return n, io.EOF
  	}
  
  	// Move to next segment.
  	r.cur++
  	r.off = 0
  	r.buf.Reset(r.segs[r.cur])
  	return n, nil
  }
docs: // Read implements io.Reader.