code: func (w *bufferedWriter) expand(file *os.File, required int) (io.Writer, error) {
  	// If there was a request to shrink the buffer, cancel that.
  	w.shrinkReq = false
  	// If there was something, flush first
  	if w.buf.Buffered() > 0 {
  		if err := w.buf.Flush(); err != nil {
  			return w.buf, err
  		}
  	}
  	// Double the size
  	w.bufSize *= 2
  	// If still smaller than what is required, adjust
  	if w.bufSize < required {
  		w.bufSize = required
  	}
  	// But cap it.
  	if w.bufSize > w.maxSize {
  		w.bufSize = w.maxSize
  	}
  	w.buf = bufio.NewWriterSize(file, w.bufSize)
  	return w.buf, nil
  }
docs: // expand the buffer (first flushing the buffer if not empty)