mirror of
https://github.com/golang/go
synced 2024-11-25 05:07:56 -07:00
godoc: fix path resolution for command-line one more time (sigh...)
R=rsc CC=golang-dev https://golang.org/cl/217058
This commit is contained in:
parent
8e714aab2b
commit
aaec61555a
@ -33,6 +33,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"os"
|
||||
pathutil "path"
|
||||
"time"
|
||||
)
|
||||
|
||||
@ -224,11 +225,29 @@ func main() {
|
||||
packageText = packageHTML
|
||||
}
|
||||
|
||||
info := pkgHandler.getPageInfo(flag.Arg(0), flag.Arg(0), true)
|
||||
// determine paths
|
||||
path := flag.Arg(0)
|
||||
if len(path) > 0 && path[0] == '.' {
|
||||
// assume cwd; don't assume -goroot
|
||||
cwd, _ := os.Getwd() // ignore errors
|
||||
path = pathutil.Join(cwd, path)
|
||||
}
|
||||
relpath := path
|
||||
abspath := path
|
||||
if len(path) > 0 && path[0] != '/' {
|
||||
abspath = absolutePath(path, pkgHandler.fsRoot)
|
||||
} else {
|
||||
relpath = relativePath(path)
|
||||
}
|
||||
|
||||
info := pkgHandler.getPageInfo(abspath, relpath, true)
|
||||
|
||||
if info.PDoc == nil && info.Dirs == nil {
|
||||
// try again, this time assume it's a command
|
||||
info = cmdHandler.getPageInfo(flag.Arg(0), flag.Arg(0), false)
|
||||
if len(path) > 0 && path[0] != '/' {
|
||||
abspath = absolutePath(path, cmdHandler.fsRoot)
|
||||
}
|
||||
info = cmdHandler.getPageInfo(abspath, relpath, false)
|
||||
}
|
||||
|
||||
if info.PDoc != nil && flag.NArg() > 1 {
|
||||
|
Loading…
Reference in New Issue
Block a user