Skip to content

Commit 4f7ec7a

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 4f7ec7a

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

src/path/filepath/path.go

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -334,19 +334,20 @@ func Rel(basepath, targpath string) (string, error) {
334334
var SkipDir = errors.New("skip this directory")
335335

336336
// WalkFunc is the type of the function called for each file or directory
337-
// visited by Walk. The path argument contains the argument to Walk as a
338-
// prefix; that is, if Walk is called with "dir", which is a directory
339-
// containing the file "a", the walk function will be called with argument
340-
// "dir/a". The info argument is the os.FileInfo for the named path.
337+
// visited by Walk. The path argument contains the argument to Walk as a prefix;
338+
// that is, if Walk is called with "dir", which is a directory containing the
339+
// file "a", the walk function will be called with argument "dir/a". The info
340+
// argument is the os.FileInfo for the named path.
341341
//
342342
// If there was a problem walking to the file or directory named by path, the
343-
// 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.
343+
// incoming error will describe the problem and the function can decide how to
344+
// 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)