]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: change example to print the correct path on failure
authorErwin Oegema <blablaechthema@hotmail.com>
Mon, 26 Mar 2018 13:21:29 +0000 (13:21 +0000)
committerBrad Fitzpatrick <bradfitz@golang.org>
Mon, 26 Mar 2018 17:40:01 +0000 (17:40 +0000)
This change makes errors in the example code a bit better, as it's no use to show the root dir when an error occurs walking a subdirectory or file.

Change-Id: I546276e9b151fabba5357258f03bfbd47a508201
GitHub-Last-Rev: 398c1eeb6164a7edc6fdee8cb8c17c3bd0b649ef
GitHub-Pull-Request: golang/go#24536
Reviewed-on: https://go-review.googlesource.com/102535
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/path/filepath/example_unix_test.go

index 40bc547fe46f2c233b747aa570f551b325586a04..fe49c12d8d3cbf7d16101743b2e006e8fa17ae84 100644 (file)
@@ -80,13 +80,14 @@ func ExampleJoin() {
        // a/b/c
        // a/b/c
 }
+
 func ExampleWalk() {
        dir := "dir/to/walk"
        subDirToSkip := "skip" // dir/to/walk/skip
 
        err := filepath.Walk(dir, func(path string, info os.FileInfo, err error) error {
                if err != nil {
-                       fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", dir, err)
+                       fmt.Printf("prevent panic by handling failure accessing a path %q: %v\n", path, err)
                        return err
                }
                if info.IsDir() && info.Name() == subDirToSkip {