-
Notifications
You must be signed in to change notification settings - Fork 18k
filepath.Walk/WalkFunc docs do not cover nil os.FileInfo argument #26425
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
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
Milestone
Comments
I'd be happy to take this one. |
jackxbritton
added a commit
to jackxbritton/go
that referenced
this issue
Jul 18, 2018
If a filepath.WalkFunc is called with an non-nil err argument, it's possible that the info argument will be nil. Now the comment above filepath.WalkFunc reflects this. Fixes golang#26425.
jackxbritton
added a commit
to jackxbritton/go
that referenced
this issue
Jul 18, 2018
If a filepath.WalkFunc is called with an non-nil err argument, it's possible that the info argument will be nil. The comment above filepath.WalkFunc now reflects this. Fixes golang#26425.
jackxbritton
added a commit
to jackxbritton/go
that referenced
this issue
Jul 18, 2018
If a filepath.WalkFunc is called with an non-nil err argument, it's possible that the info argument will be nil. The comment above filepath.WalkFunc now reflects this. Fixes golang#26425
Change https://golang.org/cl/124635 mentions this issue: |
jackxbritton
added a commit
to jackxbritton/go
that referenced
this issue
Jul 18, 2018
If a filepath.WalkFunc is called with an non-nil err argument, it's possible that the info argument will be nil. The comment above filepath.WalkFunc now reflects this. Fixes golang#26425
jackxbritton
added a commit
to jackxbritton/go
that referenced
this issue
Jul 18, 2018
If a filepath.WalkFunc is called with an non-nil err argument, it's possible that the info argument will be nil. The comment above filepath.WalkFunc now reflects this. Fixes golang#26425
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
Documentation
Issues describing a change to documentation.
FrozenDueToAge
help wanted
NeedsFix
The path to resolution is known, but the work has not been done.
What version of Go are you using (
go version
)?1.10.2
Does this issue reproduce with the latest release?
N/A, applies to docs
What operating system and processor architecture are you using (
go env
)?N/A
What did you do?
Write a WalkFunc which called a method of its info argument.
What did you expect to see?
Success.
What did you see instead?
A panic.
I think this is a documentation issue; the documentation for WalkFunc currently says only:
"[...] The info argument is the os.FileInfo for the named path.
If there was a problem walking to the file or directory named by path, the incoming error will describe the problem and the function can decide how to handle that error (and Walk will not descend into that directory). If an error is returned, processing stops. [...]"
One of these two sections should probably say that the info argument may be nil if err is not nil. In particular, note that a determination of whether to return SkipDir could be contingent on knowing whether the path refers to a file or directory, since behavior varies. Thus, it's plausible to imagine wanting to call info.IsDir(), but it's apparently unsafe if err wasn't nil.
The text was updated successfully, but these errors were encountered: