diff options
author | Ian Lance Taylor <iant@golang.org> | 2018-03-07 07:03:46 -0800 |
---|---|---|
committer | Andrew Bonventre <andybons@golang.org> | 2018-03-29 06:07:50 +0000 |
commit | 69a7f73de888c19ac6641dcd61a499404beb437c (patch) | |
tree | e95abf6923c99a39fbe0c206c63e057feb1d01b1 | |
parent | 853155f384e570635846b508d2fde7899d8d1612 (diff) | |
download | go-69a7f73de888c19ac6641dcd61a499404beb437c.tar.gz go-69a7f73de888c19ac6641dcd61a499404beb437c.zip |
[release-branch.go1.10] 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 <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-on: https://go-review.googlesource.com/102785
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
-rw-r--r-- | src/cmd/go/go_test.go | 10 | ||||
-rw-r--r-- | src/cmd/go/internal/vet/vet.go | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index 773b8240d2..63974ea0cf 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -3233,6 +3233,16 @@ func TestGoVetWithOnlyTestFiles(t *testing.T) { tg.run("vet", "p") } +// Issue 24193. +func TestVetWithOnlyCgoFiles(t *testing.T) { + tg := testgo(t) + defer tg.cleanup() + tg.parallel() + tg.tempFile("src/p/p.go", "package p; import \"C\"; func F() {}") + tg.setenv("GOPATH", tg.path(".")) + tg.run("vet", "p") +} + // Issue 9767, 19769. func TestGoGetDotSlashDownload(t *testing.T) { testenv.MustHaveExternalNetwork(t) diff --git a/src/cmd/go/internal/vet/vet.go b/src/cmd/go/internal/vet/vet.go index 3d095d4508..c792a243bf 100644 --- a/src/cmd/go/internal/vet/vet.go +++ b/src/cmd/go/internal/vet/vet.go @@ -62,11 +62,11 @@ func runVet(cmd *base.Command, args []string) { base.Errorf("%v", err) continue } - if len(ptest.GoFiles) == 0 && pxtest == nil { + if len(ptest.GoFiles) == 0 && len(ptest.CgoFiles) == 0 && pxtest == nil { base.Errorf("go vet %s: no Go files in %s", p.ImportPath, p.Dir) continue } - if len(ptest.GoFiles) > 0 { + if len(ptest.GoFiles) > 0 || len(ptest.CgoFiles) > 0 { root.Deps = append(root.Deps, b.VetAction(work.ModeBuild, work.ModeBuild, ptest)) } if pxtest != nil { |