-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmd/go/internal/vet: print line numbers appropriately on list errors
Fixes golang#36173 For reasons that are unclear to me, this commit: golang@f1d5ce0 introduces a TestPackagesFor function that strips line numbers from error messages. This commit introduces a new version of that function for 'go vet' that always keeps the line numbers.
- Loading branch information
Showing
3 changed files
with
95 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
env GO111MODULE=off | ||
|
||
# Issue 36173. Verify that "go vet" prints line numbers on load errors. | ||
|
||
! go vet a/a.go | ||
stderr 'a.go:5:3: use of internal package' | ||
|
||
! go vet a/a_test.go | ||
stderr 'a_test.go:4:3: use of internal package' | ||
|
||
! go vet a | ||
stderr 'a.go:5:3: use of internal package' | ||
|
||
go vet b/b.go | ||
! stderr 'use of internal package' | ||
|
||
! go vet b/b_test.go | ||
stderr 'b_test.go:4:3: use of internal package' | ||
|
||
! go vet depends-on-a/depends-on-a.go | ||
stderr 'a.go:5:3: use of internal package' | ||
|
||
! go vet depends-on-a/depends-on-a_test.go | ||
stderr 'package command-line-arguments \(test\)\n\timports a: use of internal package a/x/internal/y not allowed' | ||
|
||
! go vet depends-on-a | ||
stderr 'a.go:5:3: use of internal package' | ||
|
||
-- a/a.go -- | ||
// A package with bad imports in both src and test | ||
package a | ||
|
||
import ( | ||
_ "a/x/internal/y" | ||
) | ||
|
||
-- a/a_test.go -- | ||
package a | ||
|
||
import ( | ||
_ "a/x/internal/y" | ||
) | ||
|
||
-- b/b.go -- | ||
// A package with a bad import in test only | ||
package b | ||
|
||
-- b/b_test.go -- | ||
package b | ||
|
||
import ( | ||
_ "a/x/internal/y" | ||
) | ||
|
||
-- depends-on-a/depends-on-a.go -- | ||
// A package that depends on a package with a bad import | ||
package depends | ||
|
||
import ( | ||
_ "a" | ||
) | ||
|
||
-- depends-on-a/depends-on-a_test.go -- | ||
package depends | ||
|
||
import ( | ||
_ "a" | ||
) | ||
|
||
-- a/x/internal/y/y.go -- | ||
package y |