Commit 3763a395 authored by Russ Cox's avatar Russ Cox

cmd/go: adjust import comment error

Fixes #7453.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/127210043
parent 9aa1e9af
...@@ -267,7 +267,7 @@ func loadImport(path string, srcDir string, stk *importStack, importPos []token. ...@@ -267,7 +267,7 @@ func loadImport(path string, srcDir string, stk *importStack, importPos []token.
bp.BinDir = gobin bp.BinDir = gobin
} }
if err == nil && !isLocal && bp.ImportComment != "" && bp.ImportComment != path { if err == nil && !isLocal && bp.ImportComment != "" && bp.ImportComment != path {
err = fmt.Errorf("directory %s contains package %q", bp.Dir, bp.ImportComment) err = fmt.Errorf("code in directory %s expects import %q", bp.Dir, bp.ImportComment)
} }
p.load(stk, bp, err) p.load(stk, bp, err)
if p.Error != nil && len(importPos) > 0 { if p.Error != nil && len(importPos) > 0 {
......
...@@ -131,7 +131,7 @@ TEST 'import comment - mismatch' ...@@ -131,7 +131,7 @@ TEST 'import comment - mismatch'
if ./testgo build ./testdata/importcom/wrongplace.go 2>testdata/err; then if ./testgo build ./testdata/importcom/wrongplace.go 2>testdata/err; then
echo 'go build ./testdata/importcom/wrongplace.go suceeded' echo 'go build ./testdata/importcom/wrongplace.go suceeded'
ok=false ok=false
elif ! grep 'wrongplace contains package "my/x"' testdata/err >/dev/null; then elif ! grep 'wrongplace expects import "my/x"' testdata/err >/dev/null; then
echo 'go build did not mention incorrect import:' echo 'go build did not mention incorrect import:'
cat testdata/err cat testdata/err
ok=false ok=false
......
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