Skip to content

Commit

Permalink
Renamed Step func to Next() as per PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
johnepiscopo committed May 20, 2019
1 parent 434fa14 commit 74a8c4b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions walker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
10 changes: 5 additions & 5 deletions walker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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")
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 74a8c4b

Please sign in to comment.