LEFT | RIGHT |
1 // Copyright 2011 The Go Authors. All rights reserved. | 1 // Copyright 2011 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package main | 5 package main |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "go/build" | 9 "go/build" |
10 "os" | 10 "os" |
(...skipping 13 matching lines...) Expand all Loading... |
24 With no arguments it prints the list of known tools. | 24 With no arguments it prints the list of known tools. |
25 | 25 |
26 For more about each tool command, see 'go tool command -h'. | 26 For more about each tool command, see 'go tool command -h'. |
27 `, | 27 `, |
28 } | 28 } |
29 | 29 |
30 var ( | 30 var ( |
31 toolGOOS = runtime.GOOS | 31 toolGOOS = runtime.GOOS |
32 toolGOARCH = runtime.GOARCH | 32 toolGOARCH = runtime.GOARCH |
33 toolIsWindows = toolGOOS == "windows" | 33 toolIsWindows = toolGOOS == "windows" |
34 » toolDir = filepath.Join(build.Path[0].Path, "bin", "tool", toolGOO
S+"_"+toolGOARCH) | 34 » toolDir = build.ToolDir |
35 ) | 35 ) |
36 | 36 |
37 const toolWindowsExtension = ".exe" | 37 const toolWindowsExtension = ".exe" |
38 | 38 |
39 func tool(name string) string { | 39 func tool(name string) string { |
40 p := filepath.Join(toolDir, name) | 40 p := filepath.Join(toolDir, name) |
41 if toolIsWindows { | 41 if toolIsWindows { |
42 p += toolWindowsExtension | 42 p += toolWindowsExtension |
43 } | 43 } |
44 return p | 44 return p |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 for _, name := range names { | 102 for _, name := range names { |
103 // Unify presentation by going to lower case. | 103 // Unify presentation by going to lower case. |
104 name = strings.ToLower(name) | 104 name = strings.ToLower(name) |
105 // If it's windows, don't show the .exe suffix. | 105 // If it's windows, don't show the .exe suffix. |
106 if toolIsWindows && strings.HasSuffix(name, toolWindowsExtension
) { | 106 if toolIsWindows && strings.HasSuffix(name, toolWindowsExtension
) { |
107 name = name[:len(name)-len(toolWindowsExtension)] | 107 name = name[:len(name)-len(toolWindowsExtension)] |
108 } | 108 } |
109 fmt.Println(name) | 109 fmt.Println(name) |
110 } | 110 } |
111 } | 111 } |
LEFT | RIGHT |