var cmdTool = &Command{
Run: runTool,
- UsageLine: "tool command [args...]",
+ UsageLine: "tool [-n] command [args...]",
Short: "run specified go tool",
Long: `
Tool runs the go tool command identified by the arguments.
With no arguments it prints the list of known tools.
+The -n flag causes tool to print the command that would be
+executed but not execute it.
+
For more about each tool command, see 'go tool command -h'.
`,
}
toolGOARCH = runtime.GOARCH
toolIsWindows = toolGOOS == "windows"
toolDir = build.ToolDir
+
+ toolN bool
)
+func init() {
+ cmdTool.Flag.BoolVar(&toolN, "n", false, "")
+}
+
const toolWindowsExtension = ".exe"
func tool(name string) string {
setExitStatus(3)
return
}
+
+ if toolN {
+ fmt.Printf("%s %s\n", toolPath, strings.Join(args[1:], " "))
+ return
+ }
toolCmd := &exec.Cmd{
Path: toolPath,
Args: args,