Skip to content

Commit 9742fed

Browse files
committed
cmd/go: mention internal package path in 'use of internal package not allowed' error
Fixes golang/go#25164. Change-Id: Ieca2a22b797ada69a768cb124d03bc74517e4198 Reviewed-on: https://go-review.googlesource.com/116761 Run-TryBot: Russ Cox <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent 203abfb commit 9742fed

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

vendor/cmd/go/go_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1248,14 +1248,14 @@ func TestInternalPackagesInGOROOTAreRespected(t *testing.T) {
12481248
tg := testgo(t)
12491249
defer tg.cleanup()
12501250
tg.runFail("build", "-v", "./testdata/testinternal")
1251-
tg.grepBoth(`testinternal(\/|\\)p\.go\:3\:8\: use of internal package not allowed`, "wrong error message for testdata/testinternal")
1251+
tg.grepBoth(`testinternal(\/|\\)p\.go\:3\:8\: use of internal package net/http/internal not allowed`, "wrong error message for testdata/testinternal")
12521252
}
12531253

12541254
func TestInternalPackagesOutsideGOROOTAreRespected(t *testing.T) {
12551255
tg := testgo(t)
12561256
defer tg.cleanup()
12571257
tg.runFail("build", "-v", "./testdata/testinternal2")
1258-
tg.grepBoth(`testinternal2(\/|\\)p\.go\:3\:8\: use of internal package not allowed`, "wrote error message for testdata/testinternal2")
1258+
tg.grepBoth(`testinternal2(\/|\\)p\.go\:3\:8\: use of internal package .*internal/w not allowed`, "wrote error message for testdata/testinternal2")
12591259
}
12601260

12611261
func TestRunInternal(t *testing.T) {
@@ -1265,7 +1265,7 @@ func TestRunInternal(t *testing.T) {
12651265
tg.setenv("GOPATH", dir)
12661266
tg.run("run", filepath.Join(dir, "src/run/good.go"))
12671267
tg.runFail("run", filepath.Join(dir, "src/run/bad.go"))
1268-
tg.grepStderr(`testdata(\/|\\)src(\/|\\)run(\/|\\)bad\.go\:3\:8\: use of internal package not allowed`, "unexpected error for run/bad.go")
1268+
tg.grepStderr(`testdata(\/|\\)src(\/|\\)run(\/|\\)bad\.go\:3\:8\: use of internal package run/subdir/internal/private not allowed`, "unexpected error for run/bad.go")
12691269
}
12701270

12711271
func testMove(t *testing.T, vcs, url, base, config string) {

vendor/cmd/go/internal/load/pkg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,7 @@ func disallowInternal(srcDir string, p *Package, stk *ImportStack) *Package {
730730
perr := *p
731731
perr.Error = &PackageError{
732732
ImportStack: stk.Copy(),
733-
Err: "use of internal package not allowed",
733+
Err: "use of internal package " + p.ImportPath + " not allowed",
734734
}
735735
perr.Incomplete = true
736736
return &perr

0 commit comments

Comments
 (0)