aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2010-02-01 16:13:58 -0800
committerRobert Griesemer <gri@golang.org>2010-02-01 16:13:58 -0800
commite37495368c74c315efec888857b3ca4343745952 (patch)
tree38e650732d4e0206cc65cac9bf3582cf30db9775
parentd2fc5d68da4c6410d71366e04b61d9e8fcb679b3 (diff)
downloadgo-e37495368c74c315efec888857b3ca4343745952.tar.gz
go-e37495368c74c315efec888857b3ca4343745952.zip
don't report a couple of meaningless errors in command-line mode
R=rsc CC=golang-dev https://golang.org/cl/199045
-rw-r--r--src/cmd/godoc/godoc.go11
-rw-r--r--src/cmd/godoc/main.go4
2 files changed, 8 insertions, 7 deletions
diff --git a/src/cmd/godoc/godoc.go b/src/cmd/godoc/godoc.go
index 0ec85991e5..b49487e5b8 100644
--- a/src/cmd/godoc/godoc.go
+++ b/src/cmd/godoc/godoc.go
@@ -1036,12 +1036,13 @@ type httpHandler struct {
}
-// getPageInfo returns the PageInfo for a given package directory.
+// getPageInfo returns the PageInfo for a package directory path. If the
+// parameter try is true, no errors are logged if getPageInfo fails.
// If there is no corresponding package in the directory,
// PageInfo.PDoc is nil. If there are no subdirectories,
// PageInfo.Dirs is nil.
//
-func (h *httpHandler) getPageInfo(path string) PageInfo {
+func (h *httpHandler) getPageInfo(path string, try bool) PageInfo {
// the path is relative to h.fsroot
dirname := pathutil.Join(h.fsRoot, path)
@@ -1066,11 +1067,11 @@ func (h *httpHandler) getPageInfo(path string) PageInfo {
// get package AST
pkgs, err := parser.ParseDir(dirname, filter, parser.ParseComments)
- if err != nil {
+ if err != nil && !try {
// TODO: errors should be shown instead of an empty directory
log.Stderrf("parser.parseDir: %s", err)
}
- if len(pkgs) != 1 {
+ if len(pkgs) != 1 && !try {
// TODO: should handle multiple packages
log.Stderrf("parser.parseDir: found %d packages", len(pkgs))
}
@@ -1110,7 +1111,7 @@ func (h *httpHandler) ServeHTTP(c *http.Conn, r *http.Request) {
path := r.URL.Path
path = path[len(h.pattern):]
- info := h.getPageInfo(path)
+ info := h.getPageInfo(path, false)
var buf bytes.Buffer
if r.FormValue("f") == "text" {
diff --git a/src/cmd/godoc/main.go b/src/cmd/godoc/main.go
index 701cd006e2..7a3b9f384a 100644
--- a/src/cmd/godoc/main.go
+++ b/src/cmd/godoc/main.go
@@ -220,11 +220,11 @@ func main() {
packageText = packageHTML
}
- info := pkgHandler.getPageInfo(flag.Arg(0))
+ info := pkgHandler.getPageInfo(flag.Arg(0), true)
if info.PDoc == nil && info.Dirs == nil {
// try again, this time assume it's a command
- info = cmdHandler.getPageInfo(flag.Arg(0))
+ info = cmdHandler.getPageInfo(flag.Arg(0), false)
}
if info.PDoc != nil && flag.NArg() > 1 {