Commit 46e03c4b authored by LE Manh Cuong's avatar LE Manh Cuong Committed by Ian Lance Taylor

cmd/go: fix import current directory error message

Fixes #14683

Change-Id: I62c429e4fcc2f20a94d3db8c1f0ca587252c07a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/174130
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
parent aad2336c
......@@ -3626,7 +3626,7 @@ func TestImportLocal(t *testing.T) {
var _ = x.X
`)
tg.runFail("build", "dir/x")
tg.grepStderr("local import.*in non-local package", "did not diagnose local import")
tg.grepStderr("cannot import current directory", "did not diagnose import current directory")
// ... even in a test.
tg.tempFile("src/dir/x/xx.go", `package x
......@@ -3639,7 +3639,7 @@ func TestImportLocal(t *testing.T) {
`)
tg.run("build", "dir/x")
tg.runFail("test", "dir/x")
tg.grepStderr("local import.*in non-local package", "did not diagnose local import")
tg.grepStderr("cannot import current directory", "did not diagnose import current directory")
// ... even in an xtest.
tg.tempFile("src/dir/x/xx.go", `package x
......@@ -3652,7 +3652,7 @@ func TestImportLocal(t *testing.T) {
`)
tg.run("build", "dir/x")
tg.runFail("test", "dir/x")
tg.grepStderr("local import.*in non-local package", "did not diagnose local import")
tg.grepStderr("cannot import current directory", "did not diagnose import current directory")
}
func TestGoGetInsecure(t *testing.T) {
......
......@@ -544,9 +544,13 @@ func loadImport(pre *preload, path, srcDir string, parent *Package, stk *ImportS
if p.Internal.Local && parent != nil && !parent.Internal.Local {
perr := *p
errMsg := fmt.Sprintf("local import %q in non-local package", path)
if path == "." {
errMsg = "cannot import current directory"
}
perr.Error = &PackageError{
ImportStack: stk.Copy(),
Err: fmt.Sprintf("local import %q in non-local package", path),
Err: errMsg,
}
return setErrorPos(&perr, importPos)
}
......
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