Renamed Step func to Next() as per PR comments
This commit is contained in:
parent
434fa14f3d
commit
74a8c4bcbc
10
walker.go
10
walker.go
@ -20,10 +20,10 @@ type item struct {
|
||||
err error
|
||||
}
|
||||
|
||||
// Step advances the Walker to the next file or directory,
|
||||
// Next advances the Walker to the next file or directory,
|
||||
// which will then be available through the Path, Stat, and Err methods.
|
||||
// It returns false when the walk stops at the end of the tree.
|
||||
func (w *Walker) Step() bool {
|
||||
func (w *Walker) Next() bool {
|
||||
if w.descend && w.cur.err == nil && w.cur.entry.Type == EntryTypeFolder {
|
||||
list, err := w.serverConn.List(w.cur.path)
|
||||
if err != nil {
|
||||
@ -57,12 +57,12 @@ func (w *Walker) Step() bool {
|
||||
return true
|
||||
}
|
||||
|
||||
//SkipDir tells the step function to skip the currently processed directory
|
||||
//SkipDir tells the Next function to skip the currently processed directory
|
||||
func (w *Walker) SkipDir() {
|
||||
w.descend = false
|
||||
}
|
||||
|
||||
//Err returns the error, if any, for the most recent attempt by Step to
|
||||
//Err returns the error, if any, for the most recent attempt by Next to
|
||||
//visit a file or a directory. If a directory has an error, the walker
|
||||
//will not descend in that directory
|
||||
func (w *Walker) Err() error {
|
||||
@ -76,7 +76,7 @@ func (w *Walker) Stat() Entry {
|
||||
}
|
||||
|
||||
// Path returns the path to the most recent file or directory
|
||||
// visited by a call to Step. It contains the argument to Walk
|
||||
// visited by a call to Next. It contains the argument to Walk
|
||||
// as a prefix; that is, if Walk is called with "dir", which is
|
||||
// a directory containing the file "a", Path will return "dir/a".
|
||||
func (w *Walker) Path() string {
|
||||
|
@ -82,7 +82,7 @@ func TestNoDescendDoesNotAddToStack(t *testing.T) {
|
||||
|
||||
w.SkipDir()
|
||||
|
||||
result := w.Step()
|
||||
result := w.Next()
|
||||
|
||||
assert.Equal(t, true, result, "Result should return true")
|
||||
assert.Equal(t, 0, len(w.stack))
|
||||
@ -106,7 +106,7 @@ func TestEmptyStackReturnsFalse(t *testing.T) {
|
||||
|
||||
w.SkipDir()
|
||||
|
||||
result := w.Step()
|
||||
result := w.Next()
|
||||
|
||||
assert.Equal(t, false, result, "Result should return false")
|
||||
}
|
||||
@ -147,8 +147,8 @@ func TestCurAndStackSetCorrectly(t *testing.T) {
|
||||
},
|
||||
}
|
||||
|
||||
result := w.Step()
|
||||
result = w.Step()
|
||||
result := w.Next()
|
||||
result = w.Next()
|
||||
|
||||
assert.Equal(t, true, result, "Result should return true")
|
||||
assert.Equal(t, 0, len(w.stack))
|
||||
@ -183,7 +183,7 @@ func TestStackIsPopulatedCorrectly(t *testing.T) {
|
||||
|
||||
w.descend = true
|
||||
|
||||
w.Step()
|
||||
w.Next()
|
||||
|
||||
assert.Equal(t, 0, len(w.stack))
|
||||
assert.Equal(t, "lo", w.cur.entry.Name)
|
||||
|
Loading…
Reference in New Issue
Block a user