mirror of https://github.com/golang/go.git
cmd/go: install go.tools/cmd/godoc to $GOROOT/bin/godoc
Also suggest "go get" if godoc not found when running "go doc". R=golang-dev, r, rsc CC=golang-dev https://golang.org/cl/12214043
This commit is contained in:
parent
64cb2cf5cc
commit
e011ac5420
|
|
@ -4,6 +4,8 @@
|
|||
|
||||
package main
|
||||
|
||||
import "os/exec"
|
||||
|
||||
func init() {
|
||||
addBuildFlagsNX(cmdFmt)
|
||||
addBuildFlagsNX(cmdDoc)
|
||||
|
|
@ -59,6 +61,11 @@ See also: go fix, go fmt, go vet.
|
|||
}
|
||||
|
||||
func runDoc(cmd *Command, args []string) {
|
||||
_, err := exec.LookPath("godoc")
|
||||
if err != nil {
|
||||
errorf("go doc: can't find godoc; to install:\n\tgo get code.google.com/p/go.tools/cmd/godoc")
|
||||
return
|
||||
}
|
||||
for _, pkg := range packages(args) {
|
||||
if pkg.ImportPath == "command-line arguments" {
|
||||
errorf("go doc: cannot use package file list")
|
||||
|
|
|
|||
|
|
@ -283,15 +283,23 @@ func reusePackage(p *Package, stk *importStack) *Package {
|
|||
return p
|
||||
}
|
||||
|
||||
// isGoTool is the list of directories for Go programs that are installed in
|
||||
// $GOROOT/pkg/tool.
|
||||
var isGoTool = map[string]bool{
|
||||
"cmd/api": true,
|
||||
"cmd/cgo": true,
|
||||
"cmd/fix": true,
|
||||
"cmd/yacc": true,
|
||||
"code.google.com/p/go.tools/cmd/cover": true,
|
||||
"code.google.com/p/go.tools/cmd/vet": true,
|
||||
type targetDir int
|
||||
|
||||
const (
|
||||
toRoot targetDir = iota // to bin dir inside package root (default)
|
||||
toTool // GOROOT/pkg/tool
|
||||
toBin // GOROOT/bin
|
||||
)
|
||||
|
||||
// goTools is a map of Go program import path to install target directory.
|
||||
var goTools = map[string]targetDir{
|
||||
"cmd/api": toTool,
|
||||
"cmd/cgo": toTool,
|
||||
"cmd/fix": toTool,
|
||||
"cmd/yacc": toTool,
|
||||
"code.google.com/p/go.tools/cmd/cover": toTool,
|
||||
"code.google.com/p/go.tools/cmd/godoc": toBin,
|
||||
"code.google.com/p/go.tools/cmd/vet": toTool,
|
||||
}
|
||||
|
||||
// expandScanner expands a scanner.List error into all the errors in the list.
|
||||
|
|
@ -341,11 +349,15 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package
|
|||
// Install cross-compiled binaries to subdirectories of bin.
|
||||
elem = full
|
||||
}
|
||||
if p.build.BinDir != "" {
|
||||
p.target = filepath.Join(p.build.BinDir, elem)
|
||||
}
|
||||
if isGoTool[p.ImportPath] {
|
||||
switch goTools[p.ImportPath] {
|
||||
case toRoot: // default, if p.ImportPath not in goTools
|
||||
if p.build.BinDir != "" {
|
||||
p.target = filepath.Join(p.build.BinDir, elem)
|
||||
}
|
||||
case toTool:
|
||||
p.target = filepath.Join(gorootPkg, "tool", full)
|
||||
case toBin:
|
||||
p.target = filepath.Join(gorootBin, elem)
|
||||
}
|
||||
if p.target != "" && buildContext.GOOS == "windows" {
|
||||
p.target += ".exe"
|
||||
|
|
|
|||
Loading…
Reference in New Issue