Skip to content

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

@seebs

Description

@seebs

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DocumentationIssues describing a change to documentation.FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.help wanted

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions