Skip to content

Commit 709da95

Browse files
cmd/go: run vet on packages with only cgo files
CgoFiles is not included in GoFiles, so we need to check both. Fixes #24193 Change-Id: I6a67bd912e3d9a4be0eae8fa8db6fa8a07fb5df3 Reviewed-on: https://go-review.googlesource.com/99175 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent a3b3284 commit 709da95

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/cmd/go/go_test.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3233,6 +3233,16 @@ func TestGoVetWithOnlyTestFiles(t *testing.T) {
32333233
tg.run("vet", "p")
32343234
}
32353235

3236+
// Issue 24193.
3237+
func TestVetWithOnlyCgoFiles(t *testing.T) {
3238+
tg := testgo(t)
3239+
defer tg.cleanup()
3240+
tg.parallel()
3241+
tg.tempFile("src/p/p.go", "package p; import \"C\"; func F() {}")
3242+
tg.setenv("GOPATH", tg.path("."))
3243+
tg.run("vet", "p")
3244+
}
3245+
32363246
// Issue 9767, 19769.
32373247
func TestGoGetDotSlashDownload(t *testing.T) {
32383248
testenv.MustHaveExternalNetwork(t)

src/cmd/go/internal/vet/vet.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,11 @@ func runVet(cmd *base.Command, args []string) {
6262
base.Errorf("%v", err)
6363
continue
6464
}
65-
if len(ptest.GoFiles) == 0 && pxtest == nil {
65+
if len(ptest.GoFiles) == 0 && len(ptest.CgoFiles) == 0 && pxtest == nil {
6666
base.Errorf("go vet %s: no Go files in %s", p.ImportPath, p.Dir)
6767
continue
6868
}
69-
if len(ptest.GoFiles) > 0 {
69+
if len(ptest.GoFiles) > 0 || len(ptest.CgoFiles) > 0 {
7070
root.Deps = append(root.Deps, b.VetAction(work.ModeBuild, work.ModeBuild, ptest))
7171
}
7272
if pxtest != nil {

0 commit comments

Comments
 (0)