diff options
| author | Rob Pike <r@golang.org> | 2013-05-21 21:18:10 -0700 |
|---|---|---|
| committer | Rob Pike <r@golang.org> | 2013-05-21 21:18:10 -0700 |
| commit | 23dec8d1907f85d487b2adf3f0672c2cc02e4ce6 (patch) | |
| tree | 69158b370b665da62a92991417690474c470d06f /src | |
| parent | c9121507610390a6bb0b00bb3ebbf45e54c9c776 (diff) | |
| download | go-23dec8d1907f85d487b2adf3f0672c2cc02e4ce6.tar.xz | |
cmd/go: support new location for vet
Also delete the special case for exp, which isn't necessary any more.
Fixes #5529.
R=rsc, nightlyone
CC=golang-dev
https://golang.org/cl/9611048
Diffstat (limited to 'src')
| -rw-r--r-- | src/cmd/go/pkg.go | 12 | ||||
| -rw-r--r-- | src/cmd/go/tool.go | 34 |
2 files changed, 30 insertions, 16 deletions
diff --git a/src/cmd/go/pkg.go b/src/cmd/go/pkg.go index b33d800bfb..a629d610f4 100644 --- a/src/cmd/go/pkg.go +++ b/src/cmd/go/pkg.go @@ -272,11 +272,11 @@ func reusePackage(p *Package, stk *importStack) *Package { // 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/vet": true, - "cmd/yacc": true, + "cmd/api": true, + "cmd/cgo": true, + "cmd/fix": true, + "cmd/yacc": true, + "code.google.com/p/go.tools/cmd/vet": true, } // expandScanner expands a scanner.List error into all the errors in the list. @@ -329,7 +329,7 @@ func (p *Package) load(stk *importStack, bp *build.Package, err error) *Package if p.build.BinDir != "" { p.target = filepath.Join(p.build.BinDir, elem) } - if p.Goroot && (isGoTool[p.ImportPath] || strings.HasPrefix(p.ImportPath, "exp/")) { + if isGoTool[p.ImportPath] { p.target = filepath.Join(gorootPkg, "tool", full) } if p.target != "" && buildContext.GOOS == "windows" { diff --git a/src/cmd/go/tool.go b/src/cmd/go/tool.go index 299b94cb36..2d7db29152 100644 --- a/src/cmd/go/tool.go +++ b/src/cmd/go/tool.go @@ -45,12 +45,30 @@ func init() { const toolWindowsExtension = ".exe" -func tool(name string) string { - p := filepath.Join(toolDir, name) - if toolIsWindows && name != "pprof" { - p += toolWindowsExtension +func tool(toolName string) string { + toolPath := filepath.Join(toolDir, toolName) + if toolIsWindows && toolName != "pprof" { + toolPath += toolWindowsExtension } - return p + // Give a nice message if there is no tool with that name. + if _, err := os.Stat(toolPath); err != nil { + if isInGoToolsRepo(toolName) { + fmt.Fprintf(os.Stderr, "go tool: no such tool %q; to install:\n\tgo install code.google.com/p/go.tools/cmd/%s\n", toolName, toolName) + } else { + fmt.Fprintf(os.Stderr, "go tool: no such tool %q\n", toolName) + } + setExitStatus(3) + exit() + } + return toolPath +} + +func isInGoToolsRepo(toolName string) bool { + switch toolName { + case "vet": + return true + } + return false } func runTool(cmd *Command, args []string) { @@ -70,10 +88,7 @@ func runTool(cmd *Command, args []string) { } } toolPath := tool(toolName) - // Give a nice message if there is no tool with that name. - if _, err := os.Stat(toolPath); err != nil { - fmt.Fprintf(os.Stderr, "go tool: no such tool %q\n", toolName) - setExitStatus(3) + if toolPath == "" { return } if toolIsWindows && toolName == "pprof" { @@ -86,7 +101,6 @@ func runTool(cmd *Command, args []string) { return } } - if toolN { fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " ")) return |
