code: func (w *WAL) Truncate(i int) (err error) {
  	w.truncateTotal.Inc()
  	defer func() {
  		if err != nil {
  			w.truncateFail.Inc()
  		}
  	}()
  	refs, err := listSegments(w.dir)
  	if err != nil {
  		return err
  	}
  	for _, r := range refs {
  		if r.index >= i {
  			break
  		}
  		if err = os.Remove(filepath.Join(w.dir, r.name)); err != nil {
  			return err
  		}
  	}
  	return nil
  }
docs: // Truncate drops all segments before i.