diff options
Diffstat (limited to 'src/cmd/go/tool.go')
-rw-r--r-- | src/cmd/go/tool.go | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/src/cmd/go/tool.go b/src/cmd/go/tool.go index 299b94cb3..6d26f7a4b 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 get 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 "cover", "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 |