]> Cypherpunks repositories - gostls13.git/commitdiff
path/filepath: document that Glob ignores i/o errors
authorRuss Cox <rsc@golang.org>
Fri, 19 Sep 2014 01:50:22 +0000 (21:50 -0400)
committerRuss Cox <rsc@golang.org>
Fri, 19 Sep 2014 01:50:22 +0000 (21:50 -0400)
Fixes #8008.

LGTM=adg
R=golang-codereviews, nightlyone, adg
CC=golang-codereviews
https://golang.org/cl/138630045

src/path/filepath/match.go

index a9bcc103c5512ffb30d288df10bd557735c58c67..ecc07aa5dac186a3adc4f483b8089fd74266b591 100644 (file)
@@ -228,6 +228,9 @@ func getEsc(chunk string) (r rune, nchunk string, err error) {
 // as in Match. The pattern may describe hierarchical names such as
 // /usr/*/bin/ed (assuming the Separator is '/').
 //
+// Glob ignores file system errors such as I/O errors reading directories.
+// The only possible returned error is ErrBadPattern, when pattern
+// is malformed.
 func Glob(pattern string) (matches []string, err error) {
        if !hasMeta(pattern) {
                if _, err = os.Lstat(pattern); err != nil {
@@ -283,10 +286,7 @@ func glob(dir, pattern string, matches []string) (m []string, e error) {
        }
        defer d.Close()
 
-       names, err := d.Readdirnames(-1)
-       if err != nil {
-               return
-       }
+       names, _ := d.Readdirnames(-1)
        sort.Strings(names)
 
        for _, n := range names {