diff options
| author | Ian Lance Taylor <iant@golang.org> | 2016-07-06 17:11:29 -0700 |
|---|---|---|
| committer | Brad Fitzpatrick <bradfitz@golang.org> | 2016-08-25 17:18:43 +0000 |
| commit | 157fc454eccb850a0a74029a49f8d947ff1a3762 (patch) | |
| tree | 5a082689ace833b432993750cb428ca3812b161e /src/path/filepath/path.go | |
| parent | 307de6540a5e6e5c2353c410240bb0f98bab1624 (diff) | |
| download | go-157fc454eccb850a0a74029a49f8d947ff1a3762.tar.xz | |
path/filepath: don't return SkipDir at top
If the walker function called on a top-level file returns SkipDir,
then (before this change) Walk would return SkipDir, which the
documentation implies will not happen.
Fixes #16280.
Change-Id: I37d63bdcef7af4b56e342b624cf0d4b42e65c297
Reviewed-on: https://go-review.googlesource.com/24780
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'src/path/filepath/path.go')
| -rw-r--r-- | src/path/filepath/path.go | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/path/filepath/path.go b/src/path/filepath/path.go index 0dc559cdd6..3c70cd8be6 100644 --- a/src/path/filepath/path.go +++ b/src/path/filepath/path.go @@ -393,9 +393,14 @@ func walk(path string, info os.FileInfo, walkFn WalkFunc) error { func Walk(root string, walkFn WalkFunc) error { info, err := os.Lstat(root) if err != nil { - return walkFn(root, nil, err) + err = walkFn(root, nil, err) + } else { + err = walk(root, info, walkFn) } - return walk(root, info, walkFn) + if err == SkipDir { + return nil + } + return err } // readDirNames reads the directory named by dirname and returns |
