diff options
author | Brad Fitzpatrick <bradfitz@golang.org> | 2012-04-04 07:24:13 -0700 |
---|---|---|
committer | Brad Fitzpatrick <bradfitz@golang.org> | 2012-04-04 07:24:13 -0700 |
commit | c3882041a9ad91cb3ff40ca5fe7edde7d8ac07d2 (patch) | |
tree | 9c0769d577c9eb0cffbc15b9df0c11702947a971 | |
parent | d98b9dac03eda5db7352a0fa634a29162226bfea (diff) | |
download | go-c3882041a9ad91cb3ff40ca5fe7edde7d8ac07d2.tar.gz go-c3882041a9ad91cb3ff40ca5fe7edde7d8ac07d2.zip |
[release-branch.go1] cmd/go: in go get, don't try to perform discovery on non-hosts
««« 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
»»»
-rw-r--r-- | src/cmd/go/vcs.go | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/cmd/go/vcs.go b/src/cmd/go/vcs.go index 5f63f8b568..1c121672f9 100644 --- a/src/cmd/go/vcs.go +++ b/src/cmd/go/vcs.go @@ -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) |