Skip to content

Commit

Permalink
cmd/go: make malformed import path message more precise
Browse files Browse the repository at this point in the history
If you say 'go get -v' you get extra information when import
paths are not of the expected form.

If you say 'go get -v src/rsc.io/pdf' the message says that
src/rsc.io/pdf does not contain a hostname, which is incorrect.
The problem is that it does not begin with a hostname.

Fixes golang#7432.

LGTM=r
R=golang-codereviews, r
CC=bradfitz, golang-codereviews, iant
https://golang.org/cl/144650043
  • Loading branch information
rsc authored and wheatman committed Jun 25, 2018
1 parent 91d8950 commit 24e18eb
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/cmd/go/vcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,11 +539,11 @@ func repoRootForImportPathStatic(importPath, scheme string) (*repoRoot, error) {
func repoRootForImportDynamic(importPath string) (*repoRoot, error) {
slash := strings.Index(importPath, "/")
if slash < 0 {
return nil, errors.New("import path doesn't contain a slash")
return nil, errors.New("import path does not contain a slash")
}
host := importPath[:slash]
if !strings.Contains(host, ".") {
return nil, errors.New("import path doesn't contain a hostname")
return nil, errors.New("import path does not begin with hostname")
}
urlStr, body, err := httpsOrHTTP(importPath)
if err != nil {
Expand Down

0 comments on commit 24e18eb

Please sign in to comment.