From cfc24f2d4c3519c4c87628b2021f65a4725cda6b Mon Sep 17 00:00:00 2001 From: Andy Lindeman Date: Fri, 23 Feb 2018 00:59:27 +0000 Subject: [PATCH] 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 --- godoc/cmdline.go | 4 ++-- godoc/cmdline_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/godoc/cmdline.go b/godoc/cmdline.go index 7c53681347a..58fb56236c4 100644 --- a/godoc/cmdline.go +++ b/godoc/cmdline.go @@ -69,8 +69,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 602f2bbaba5..be62148996f 100644 --- a/godoc/cmdline_test.go +++ b/godoc/cmdline_test.go @@ -202,7 +202,7 @@ package main p: p, c: c, pattern: "/cmd/", - fsRoot: "/src/cmd", + fsRoot: "/src", } p.pkgHandler = handlerServer{ p: p,