]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/godoc: fix directory read
authorRuss Cox <rsc@golang.org>
Mon, 12 Mar 2012 17:10:37 +0000 (13:10 -0400)
committerRuss Cox <rsc@golang.org>
Mon, 12 Mar 2012 17:10:37 +0000 (13:10 -0400)
Undo CL 5783076 and apply correct fix.

The /doc hack is wrong.  The code to handle this case was
already there and just needs a simple fix:

  // We didn't find any directories containing Go files.
  // If some directory returned successfully, use that.
- if len(all) == 0 && first != nil {
+ if !haveGo {
  for _, d := range first {
  haveName[d.Name()] = true
  all = append(all, d)

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/5783079

src/cmd/godoc/filesystem.go

index 869e23ca25220e0002e5f5c0b4b5352ccc8f34ba..e7092ff287a0ad0128b8432f763f7497091a200e 100644 (file)
@@ -420,17 +420,11 @@ func (ns nameSpace) ReadDir(path string) ([]os.FileInfo, error) {
                        first = dir
                }
 
-               useFiles := false
-
-               // Always include all files under /doc.
-               if path == "/doc" || strings.HasPrefix(path, "/doc/") {
-                       useFiles = true // always include docs
-               }
-
                // 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.
-               if !useFiles && !haveGo {
+               useFiles := false
+               if !haveGo {
                        for _, d := range dir {
                                if strings.HasSuffix(d.Name(), ".go") {
                                        useFiles = true
@@ -451,10 +445,12 @@ func (ns nameSpace) ReadDir(path string) ([]os.FileInfo, error) {
 
        // We didn't find any directories containing Go files.
        // If some directory returned successfully, use that.
-       if len(all) == 0 && first != nil {
+       if !haveGo {
                for _, d := range first {
-                       haveName[d.Name()] = true
-                       all = append(all, d)
+                       if !haveName[d.Name()] {
+                               haveName[d.Name()] = true
+                               all = append(all, d)
+                       }
                }
        }