From 74a8c4bcbc715b2eed925a97673fb36b63d13d60 Mon Sep 17 00:00:00 2001 From: John Episcopo Date: Mon, 20 May 2019 08:56:38 +0100 Subject: [PATCH] Renamed Step func to Next() as per PR comments --- walker.go | 10 +++++----- walker_test.go | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/walker.go b/walker.go index d87a1cf..e5f48f4 100644 --- a/walker.go +++ b/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 { diff --git a/walker_test.go b/walker_test.go index 81877af..f4a4aeb 100644 --- a/walker_test.go +++ b/walker_test.go @@ -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)