}
}
- list, err := fs.ReadDir(path)
- if err != nil {
- // newDirTree is called with a path that should be a package
- // directory; errors here should not happen, but if they do,
- // we want to know about them
- log.Printf("ReadDir(%s): %s", path, err)
- }
+ list, _ := fs.ReadDir(path)
// determine number of subdirectories and if there are package files
ndirs := 0
haveName = map[string]bool{}
all []os.FileInfo
err error
+ first []os.FileInfo
)
for _, m := range ns.resolve(path) {
continue
}
+ if dir == nil {
+ dir = []os.FileInfo{}
+ }
+
+ if first == nil {
+ first = dir
+ }
+
// If we don't yet have Go files in 'all' and this directory
// has some, add all the files from this directory.
// Otherwise, only add subdirectories.
}
}
+ // We didn't find any directories containing Go files.
+ // If some directory returned successfully, use that.
+ if len(all) == 0 && first != nil {
+ for _, d := range first {
+ haveName[d.Name()] = true
+ all = append(all, d)
+ }
+ }
+
// Built union. Add any missing directories needed to reach mount points.
for old := range ns {
if hasPathPrefix(old, path) && old != path {
list, err := fs.ReadDir(abspath)
if err != nil {
- log.Printf("ReadDir: %s", err)
serveError(w, r, relpath, err)
return
}