Commit a8197456 authored by Brad Fitzpatrick's avatar Brad Fitzpatrick

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
parent ac51c138
......@@ -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)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment