aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuss Cox <rsc@golang.org>2015-07-14 15:08:10 -0400
committerRuss Cox <rsc@golang.org>2015-07-15 04:44:54 +0000
commit2f54de0df8cf362a4ffd374e2eb752b0c57115d5 (patch)
treee218b5a61ce3c5b5e3e430768bf5c1e37922934c
parentaf96030150217fe711eac5ee994b44705bfb6832 (diff)
downloadgo-2f54de0df8cf362a4ffd374e2eb752b0c57115d5.tar.xz
cmd/go: accept go get domain.root
Fixes #9357. Change-Id: I11f0652758c4ea80debec29c3b99a72baca6d745 Reviewed-on: https://go-review.googlesource.com/12193 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r--src/cmd/go/go_test.go27
-rw-r--r--src/cmd/go/vcs.go4
2 files changed, 29 insertions, 2 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go
index 1f3615f498..1e7388467b 100644
--- a/src/cmd/go/go_test.go
+++ b/src/cmd/go/go_test.go
@@ -2133,6 +2133,7 @@ func TestGoGetUpdate(t *testing.T) {
// golang.org/issue/9224.
// The recursive updating was trying to walk to
// former dependencies, not current ones.
+
testenv.MustHaveExternalNetwork(t)
tg := testgo(t)
@@ -2157,3 +2158,29 @@ func TestGoGetUpdate(t *testing.T) {
rewind()
tg.run("get", "-d", "-u", "github.com/rsc/go-get-issue-9224-cmd")
}
+
+func TestGoGetDomainRoot(t *testing.T) {
+ // golang.org/issue/9357.
+ // go get foo.io (not foo.io/subdir) was not working consistently.
+
+ testenv.MustHaveExternalNetwork(t)
+
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.makeTempdir()
+ tg.setenv("GOPATH", tg.path("."))
+
+ // go-get-issue-9357.appspot.com is running
+ // the code at github.com/rsc/go-get-issue-9357,
+ // a trivial Go on App Engine app that serves a
+ // <meta> tag for the domain root.
+ tg.run("get", "-d", "go-get-issue-9357.appspot.com")
+ tg.run("get", "go-get-issue-9357.appspot.com")
+ tg.run("get", "-u", "go-get-issue-9357.appspot.com")
+
+ tg.must(os.RemoveAll(tg.path("src/go-get-issue-9357.appspot.com")))
+ tg.run("get", "go-get-issue-9357.appspot.com")
+
+ tg.must(os.RemoveAll(tg.path("src/go-get-issue-9357.appspot.com")))
+ tg.run("get", "-u", "go-get-issue-9357.appspot.com")
+}
diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go
index 29433de541..5393801ca5 100644
--- a/src/cmd/go/vcs.go
+++ b/src/cmd/go/vcs.go
@@ -650,11 +650,11 @@ func repoRootForImportPathStatic(importPath, scheme string, security securityMod
// repoRootForImportDynamic finds a *repoRoot for a custom domain that's not
// statically known by repoRootForImportPathStatic.
//
-// This handles custom import paths like "name.tld/pkg/foo".
+// This handles custom import paths like "name.tld/pkg/foo" or just "name.tld".
func repoRootForImportDynamic(importPath string, security securityMode) (*repoRoot, error) {
slash := strings.Index(importPath, "/")
if slash < 0 {
- return nil, errors.New("import path does not contain a slash")
+ slash = len(importPath)
}
host := importPath[:slash]
if !strings.Contains(host, ".") {