]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1] cmd/go: in go get, don't try to perform discovery on non-hosts
authorBrad Fitzpatrick <bradfitz@golang.org>
Wed, 4 Apr 2012 14:24:13 +0000 (07:24 -0700)
committerBrad Fitzpatrick <bradfitz@golang.org>
Wed, 4 Apr 2012 14:24:13 +0000 (07:24 -0700)
««« backport 2a52a9484c10
cmd/go: in go get, don't try to perform discovery on non-hosts

Before, "go get -v foo/bar" was assuming "foo" was a hostname
and trying to perform discovery on it. Now, require a dot in
the first path component (the hostname).

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/5981057
»»»

src/cmd/go/vcs.go

index 5f63f8b5683c9a63916f206b3fcbbb3f109627d6..1c121672f99c3303ad7998a038ad11bb9b5c2742 100644 (file)
@@ -422,11 +422,15 @@ func repoRootForImportPathStatic(importPath, scheme string) (*repoRoot, error) {
 func repoRootForImportDynamic(importPath string) (*repoRoot, error) {
        slash := strings.Index(importPath, "/")
        if slash < 0 {
-               return nil, fmt.Errorf("missing / in import %q", importPath)
+               return nil, errors.New("import path doesn't contain a slash")
+       }
+       host := importPath[:slash]
+       if !strings.Contains(host, ".") {
+               return nil, errors.New("import path doesn't contain a hostname")
        }
        urlStr, body, err := httpsOrHTTP(importPath)
        if err != nil {
-               return nil, fmt.Errorf("http/https fetch for import %q: %v", importPath, err)
+               return nil, fmt.Errorf("http/https fetch: %v", err)
        }
        defer body.Close()
        metaImport, err := matchGoImport(parseMetaGoImports(body), importPath)