Skip to content

Commit

Permalink
godoc: correct abspath when looking for cmds
Browse files Browse the repository at this point in the history
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: cfc24f2
GitHub-Pull-Request: #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>
  • Loading branch information
alindeman authored and bradfitz committed Jun 13, 2018
1 parent 9a70f1f commit e1f9090
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions godoc/cmdline.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
2 changes: 1 addition & 1 deletion godoc/cmdline_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ package main
p: p,
c: c,
pattern: "/cmd/",
fsRoot: "/src/cmd",
fsRoot: "/src",
}
p.pkgHandler = handlerServer{
p: p,
Expand Down

0 comments on commit e1f9090

Please sign in to comment.