code: func (w *SegmentWAL) cut() error {
  	// Sync current head to disk and close.
  	if hf := w.head(); hf != nil {
  		if err := w.flush(); err != nil {
  			return err
  		}
  		// Finish last segment asynchronously to not block the WAL moving along
  		// in the new segment.
  		go func() {
  			w.actorc <- func() error {
  				off, err := hf.Seek(0, io.SeekCurrent)
  				if err != nil {
  					return errors.Wrapf(err, "finish old segment %s", hf.Name())
  				}
  				if err := hf.Truncate(off); err != nil {
  					return errors.Wrapf(err, "finish old segment %s", hf.Name())
  				}
  				if err := hf.Sync(); err != nil {
  					return errors.Wrapf(err, "finish old segment %s", hf.Name())
  				}
  				if err := hf.Close(); err != nil {
  					return errors.Wrapf(err, "finish old segment %s", hf.Name())
  				}
  				return nil
  			}
  		}()
  	}
  
  	p, _, err := nextSequenceFile(w.dirFile.Name())
  	if err != nil {
  		return err
  	}
  	f, err := w.createSegmentFile(p)
  	if err != nil {
  		return err
  	}
  
  	go func() {
  		w.actorc <- func() error {
  			return errors.Wrap(w.dirFile.Sync(), "sync WAL directory")
  		}
  	}()
  
  	w.files = append(w.files, newSegmentFile(f))
  
  	// TODO(gouthamve): make the buffer size a constant.
  	w.cur = bufio.NewWriterSize(f, 8*1024*1024)
  	w.curN = 8
  
  	return nil
  }
docs: // cut finishes the currently active segments and opens the next one.
  // The encoder is reset to point to the new segment.