wal/util.go
func searchIndex(lg *zap.Logger, names []string, index uint64) (int, bool) {
	for i := len(names) - 1; i >= 0; i-- {
		name := names[i]
		_, curIndex, err := parseWALName(name)
		if err != nil {
			if lg != nil {
				lg.Panic("failed to parse WAL file name", zap.String("path", name), zap.Error(err))
			} else {
				plog.Panicf("parse correct name should never fail: %v", err)
			}
		}
		if index >= curIndex {
			return i, true
		}
	}
	return -1, false
}
func searchIndex(lg *zap.Logger, names []string, index uint64) (int, bool) {
	for i := len(names) - 1; i >= 0; i-- {
		name := names[i]
		_, curIndex, err := parseWALName(name)
		if err != nil {
			if lg != nil {
				lg.Panic("failed to parse WAL file name", zap.String("path", name), zap.Error(err))
			} else {
				plog.Panicf("parse correct name should never fail: %v", err)
			}
		}
		if index >= curIndex {
			return i, true
		}
	}
	return -1, false
}
func searchIndex ( lg * zap . Logger , names [ ] string , index uint64 ) ( int , bool ) { for i := len ( names ) - 1 ; i >= 0 ; i -- { name := names [ i ] _ , curIndex , err := parseWALName ( name ) if err != nil { if lg != nil { lg . Panic ( " " , zap . String ( " " , name ) , zap . Error ( err ) ) } else { plog . Panicf ( " " , err ) } } if index >= curIndex { return i , true } } return - 1 , false }
// searchIndex returns the last array index of names whose raft index section is
// equal to or smaller than the given index.
// The given names MUST be sorted.
searchIndex returns the last array index of names whose raft index section is equal to or smaller than the given index . The given names MUST be sorted .