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

filepath.Walk/WalkFunc docs do not cover nil os.FileInfo argument #26425

Closed
seebs opened this issue Jul 17, 2018 · 2 comments
Closed

filepath.Walk/WalkFunc docs do not cover nil os.FileInfo argument #26425

seebs opened this issue Jul 17, 2018 · 2 comments
Labels
Documentation FrozenDueToAge help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@seebs
Copy link
Contributor

seebs commented Jul 17, 2018

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.

@ianlancetaylor ianlancetaylor added help wanted NeedsFix The path to resolution is known, but the work has not been done. labels Jul 17, 2018
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Jul 17, 2018
@jackxbritton
Copy link
Contributor

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
@gopherbot
Copy link

Change https://golang.org/cl/124635 mentions this issue: filepath: updates doc to give case where WalkFunc info arg may be nil

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
@golang golang locked and limited conversation to collaborators Jul 18, 2019
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.
Projects
None yet
Development

No branches or pull requests

4 participants