1
0
mirror of https://github.com/golang/go synced 2024-11-23 09:00:04 -07:00

path/filepath: document that Glob ignores i/o errors

Fixes #8008.

LGTM=adg
R=golang-codereviews, nightlyone, adg
CC=golang-codereviews
https://golang.org/cl/138630045
This commit is contained in:
Russ Cox 2014-09-18 21:50:22 -04:00
parent 5fdea3430a
commit 54b63f0647

View 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 // as in Match. The pattern may describe hierarchical names such as
// /usr/*/bin/ed (assuming the Separator is '/'). // /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) { func Glob(pattern string) (matches []string, err error) {
if !hasMeta(pattern) { if !hasMeta(pattern) {
if _, err = os.Lstat(pattern); err != nil { 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() defer d.Close()
names, err := d.Readdirnames(-1) names, _ := d.Readdirnames(-1)
if err != nil {
return
}
sort.Strings(names) sort.Strings(names)
for _, n := range names { for _, n := range names {