code: func (in *BufferedIndexInput) refill() error {
  	start := in.bufferStart + int64(in.bufferPosition)
  	end := start + int64(in.bufferSize)
  	if n := in.spi.Length(); end > n { // don't read past EOF
  		end = n
  	}
  	newLength := int(end - start)
  	if newLength <= 0 {
  		return errors.New(fmt.Sprintf("read past EOF: %v", in))
  	}
  
  	if in.buffer == nil {
  		in.newBuffer(make([]byte, in.bufferSize)) // allocate buffer lazily
  		in.spi.seekInternal(int64(in.bufferStart))
  	}
  	in.spi.readInternal(in.buffer[0:newLength])
  	in.bufferLength = newLength
  	in.bufferStart = start
  	in.bufferPosition = 0
  	return nil
  }
docs: // use panic/recover to handle error