Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

io/fs: errors in WalkDirFunc documentation #43536

Closed
gazerro opened this issue Jan 6, 2021 · 1 comment
Closed

io/fs: errors in WalkDirFunc documentation #43536

gazerro opened this issue Jan 6, 2021 · 1 comment
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Milestone

Comments

@gazerro
Copy link
Contributor

gazerro commented Jan 6, 2021

There are some errors in the documentation of the new fs.WalkDirFunc type, probably because copied from the filepath.WalkFunc documentation.

The fs.WalkDir function is called Walk several times instead of WalkDir as in "if Walk is called with root argument ...".

The documentation says:

if Walk is called with the root argument "x/../dir" and finds a file named "a" in that directory, the walk function will be called with argument "dir/a", not "x/../dir/a".

But if WalkDir is called with argument "x/../dir", the walk function is called with arguments "x/../dir" and a path error, and as documented below, the WalkDir will not walk into that directory so it will not call the walk function with argument "dir/a" as documented.

The documentation says:

First, if the initial os.Lstat on the root directory fails, WalkDir calls the function with path set to root, d set to nil, and err set to the error from os.Lstat.

Should be fs.Stat instead of os.Lstat. os.Lstat is related to the file system implementation.

@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. release-blocker labels Jan 7, 2021
@ianlancetaylor ianlancetaylor added this to the Go1.16 milestone Jan 7, 2021
@gopherbot
Copy link

Change https://golang.org/cl/282172 mentions this issue: io/fs: correct WalkDirFunc documentation

@golang golang locked and limited conversation to collaborators Jan 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done. release-blocker
Projects
None yet
Development

No branches or pull requests

3 participants