aboutsummaryrefslogtreecommitdiff
path: root/godoc
diff options
context:
space:
mode:
authorAndy Lindeman <andy@lindeman.io>2018-02-26 18:23:29 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2018-06-13 15:42:59 +0000
commite1f909067fba6f4764ff0dc14860b136d9181ce0 (patch)
treed12568c73de71f640f841ea470ffb579ab0ff458 /godoc
parent9a70f1fcbf8c687dc1907029b064b4de34cc1c61 (diff)
downloadgolang-x-tools-e1f909067fba6f4764ff0dc14860b136d9181ce0.tar.gz
godoc: correct abspath when looking for cmds
godoc is erroneously detecting paths like syscall and unsafe as possible commands. A previous attempt at a fix adjusted the parameters of pkgHandler in pres.go, but that change had unexpected ripple effects that broke links and other features of godoc. This change is scoped only to the godoc command line tool. cmdline_test.go is updated to match the parameters used in the real pkgHandler in pres.go. Fixes golang/go#14447 Change-Id: I8f740c6847e46523b8443722b16942192bdf9cb8 GitHub-Last-Rev: cfc24f2d4c3519c4c87628b2021f65a4725cda6b GitHub-Pull-Request: golang/tools#27 Reviewed-on: https://go-review.googlesource.com/96515 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Diffstat (limited to 'godoc')
-rw-r--r--godoc/cmdline.go4
-rw-r--r--godoc/cmdline_test.go2
2 files changed, 3 insertions, 3 deletions
diff --git a/godoc/cmdline.go b/godoc/cmdline.go
index 86861593d..54f5f7ee7 100644
--- a/godoc/cmdline.go
+++ b/godoc/cmdline.go
@@ -72,8 +72,8 @@ func CommandLine(w io.Writer, fs vfs.NameSpace, pres *Presentation, args []strin
abspath = pathpkg.Join(pres.PkgFSRoot(), toolsPath+path)
cinfo = pres.GetCmdPageInfo(abspath, relpath, mode)
if cinfo.IsEmpty() {
- // Then try $GOROOT/cmd.
- abspath = pathpkg.Join(pres.CmdFSRoot(), path)
+ // Then try $GOROOT/src/cmd.
+ abspath = pathpkg.Join(pres.CmdFSRoot(), cmdPrefix, path)
cinfo = pres.GetCmdPageInfo(abspath, relpath, mode)
}
}
diff --git a/godoc/cmdline_test.go b/godoc/cmdline_test.go
index 8c9ce22ee..cebbf70ec 100644
--- a/godoc/cmdline_test.go
+++ b/godoc/cmdline_test.go
@@ -206,7 +206,7 @@ package main
p: p,
c: c,
pattern: "/cmd/",
- fsRoot: "/src/cmd",
+ fsRoot: "/src",
}
p.pkgHandler = handlerServer{
p: p,