summaryrefslogtreecommitdiff
path: root/src/cmd/go/main.go
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2012-01-12 15:27:57 -0800
committerRuss Cox <rsc@golang.org>2012-01-12 15:27:57 -0800
commit91e84e1b9e1a468146969743e396b9bd6c8af4de (patch)
tree27d7bdb995175fd2f4f8691ecdb232f0728fe4ed /src/cmd/go/main.go
parentdcfe9c0cc9a1c5d21d530da7822920d7bca7c0d7 (diff)
downloadgo-91e84e1b9e1a468146969743e396b9bd6c8af4de.tar.gz
cmd/go: handle path to cmd directory
Now it works to run 'go install' (no args) in cmd/go. Fixes issue 2679. R=golang-dev, r CC=golang-dev http://codereview.appspot.com/5543046
Diffstat (limited to 'src/cmd/go/main.go')
-rw-r--r--src/cmd/go/main.go20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/cmd/go/main.go b/src/cmd/go/main.go
index 4b1ff357d..8ef6395f4 100644
--- a/src/cmd/go/main.go
+++ b/src/cmd/go/main.go
@@ -192,7 +192,7 @@ func importPaths(args []string) []string {
}
var out []string
for _, a := range args {
- if (strings.HasPrefix(a, "./") || strings.HasPrefix(a, "../")) && strings.Contains(a, "...") {
+ if isLocalPath(a) && strings.Contains(a, "...") {
out = append(out, allPackagesInFS(a)...)
continue
}
@@ -246,6 +246,17 @@ func run(cmdargs ...interface{}) {
}
}
+func runOut(cmdargs ...interface{}) []byte {
+ cmdline := stringList(cmdargs...)
+ out, err := exec.Command(cmdline[0], cmdline[1:]...).CombinedOutput()
+ if err != nil {
+ os.Stderr.Write(out)
+ errorf("%v", err)
+ out = nil
+ }
+ return out
+}
+
// matchPattern(pattern)(name) reports whether
// name matches pattern. Pattern is a limited glob
// pattern in which '...' means 'any string' and there
@@ -422,3 +433,10 @@ func stringList(args ...interface{}) []string {
}
return x
}
+
+// isLocalPath returns true if arg is an import path denoting
+// a local file system directory. That is, it returns true if the
+// path begins with ./ or ../ .
+func isLocalPath(arg string) bool {
+ return arg == "." || arg == ".." || strings.HasPrefix(arg, "./") || strings.HasPrefix(arg, "../")
+}