mirror of
https://github.com/golang/go
synced 2024-11-20 02:24:43 -07:00
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
This commit is contained in:
parent
ac51c1384a
commit
a8197456b1
@ -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)
|
||||
|
Loading…
Reference in New Issue
Block a user