Skip to content

Commit 93311ae

Browse files
committed
Fix #122: don't crash govet on tests-only packages
1 parent ebbfc26 commit 93311ae

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

Diff for: .travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ script: make check_generated test
77

88
after_success:
99
- test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
10+
- echo "travis go version='$TRAVIS_GO_VERSION'"
1011

1112
# needed for the docker pipe
1213
services:
@@ -18,4 +19,4 @@ deploy:
1819
script: curl -sL https://git.io/goreleaser | bash
1920
on:
2021
tags: true
21-
condition: $TRAVIS_GO_VERSION =~ ^1\.10\.[0-9]+$
22+
condition: $TRAVIS_GO_VERSION =~ ^1\.10\.

Diff for: pkg/golinters/govet.go

+6
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,9 @@ func (g Govet) runOnInstalledPackages(ctx context.Context, lintCtx *linter.Conte
7676
astFiles = append(astFiles, af.F)
7777
fset = af.Fset
7878
}
79+
if len(astFiles) == 0 {
80+
continue
81+
}
7982
issues, err := govetAPI.Analyze(astFiles, fset, nil,
8083
lintCtx.Settings().Govet.CheckShadowing)
8184
if err != nil {
@@ -216,6 +219,9 @@ func (g Govet) runOnSourcePackages(ctx context.Context, lintCtx *linter.Context)
216219
// TODO: check .S asm files: govet can do it if pass dirs
217220
var govetIssues []govetAPI.Issue
218221
for _, pkg := range lintCtx.Program.InitialPackages() {
222+
if len(pkg.Files) == 0 {
223+
continue
224+
}
219225
issues, err := govetAPI.Analyze(pkg.Files, lintCtx.Program.Fset, pkg,
220226
lintCtx.Settings().Govet.CheckShadowing)
221227
if err != nil {

0 commit comments

Comments
 (0)