aboutsummaryrefslogtreecommitdiff
path: root/src/pkg
diff options
context:
space:
mode:
authorRob Pike <r@golang.org>2012-10-17 16:00:09 +1100
committerRob Pike <r@golang.org>2012-10-17 16:00:09 +1100
commitec1ef16cea9b9e9dd671fa30ff2d4546ec6c1dac (patch)
tree32c6d8eec1a4f86cd46d118ccf3611e9571a8d65 /src/pkg
parent8c2b131cd11cde8b8d3008e22604b366694fb083 (diff)
downloadgo-ec1ef16cea9b9e9dd671fa30ff2d4546ec6c1dac.tar.xz
path/filepath: better documentation for WalkFunc
Define the properties of the arguments better. In particular, explain that the path is (sort of) relative to the argument to Walk. Fixes #4119. R=golang-dev, iant CC=golang-dev https://golang.org/cl/6721048
Diffstat (limited to 'src/pkg')
-rw-r--r--src/pkg/path/filepath/path.go19
1 files changed, 12 insertions, 7 deletions
diff --git a/src/pkg/path/filepath/path.go b/src/pkg/path/filepath/path.go
index bb27f1c851..730c2dfb51 100644
--- a/src/pkg/path/filepath/path.go
+++ b/src/pkg/path/filepath/path.go
@@ -325,13 +325,18 @@ func Rel(basepath, targpath string) (string, error) {
var SkipDir = errors.New("skip this directory")
// WalkFunc is the type of the function called for each file or directory
-// visited by Walk. 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. The
-// sole exception is that if path is a directory and the function returns the
-// special value SkipDir, the contents of the directory are skipped
-// and processing continues as usual on the next file.
+// visited by Walk. The path argument contains the argument to Walk as a
+// prefix; that is, if Walk is called with "dir", which is a directory
+// containing the file "a", the walk function will be called with argument
+// "dir/a". 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. The sole exception is that if path
+// is a directory and the function returns the special value SkipDir, the
+// contents of the directory are skipped and processing continues as usual on
+// the next file.
type WalkFunc func(path string, info os.FileInfo, err error) error
// walk recursively descends path, calling w.