Skip to content

Commit 86129d0

Browse files
committed
filepath: updates doc to give case where WalkFunc info arg may be nil
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 #26425
1 parent e161b1e commit 86129d0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/path/filepath/path.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -341,12 +341,13 @@ var SkipDir = errors.New("skip this directory")
341341
//
342342
// If there was a problem walking to the file or directory named by path, the
343343
// incoming error will describe the problem and the function can decide how
344-
// to handle that error (and Walk will not descend into that directory). If
345-
// an error is returned, processing stops. The sole exception is when the function
346-
// returns the special value SkipDir. If the function returns SkipDir when invoked
347-
// on a directory, Walk skips the directory's contents entirely.
348-
// If the function returns SkipDir when invoked on a non-directory file,
349-
// Walk skips the remaining files in the containing directory.
344+
// to handle that error (and Walk will not descend into that directory). In the
345+
// case of an error, the info argument may be nil. If an error is returned,
346+
// processing stops. The sole exception is when the function returns the special
347+
// value SkipDir. If the function returns SkipDir when invoked on a directory,
348+
// Walk skips the directory's contents entirely. If the function returns SkipDir
349+
// when invoked on a non-directory file, Walk skips the remaining files in the
350+
// containing directory.
350351
type WalkFunc func(path string, info os.FileInfo, err error) error
351352

352353
var lstat = os.Lstat // for testing

0 commit comments

Comments
 (0)