// 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.
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" {
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) {
}
}
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" {
return
}
}
-
if toolN {
fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " "))
return