Fix #122: don't crash govet on tests-only packages

This commit is contained in:
Denis Isaev 2018-06-19 16:32:36 +03:00
parent ebbfc26e88
commit 93311aee9b
2 changed files with 8 additions and 1 deletions

View File

@ -7,6 +7,7 @@ script: make check_generated test
after_success:
- test -n "$TRAVIS_TAG" && docker login -u="$DOCKER_USERNAME" -p="$DOCKER_PASSWORD"
- echo "travis go version='$TRAVIS_GO_VERSION'"
# needed for the docker pipe
services:
@ -18,4 +19,4 @@ deploy:
script: curl -sL https://git.io/goreleaser | bash
on:
tags: true
condition: $TRAVIS_GO_VERSION =~ ^1\.10\.[0-9]+$
condition: $TRAVIS_GO_VERSION =~ ^1\.10\.

View File

@ -76,6 +76,9 @@ func (g Govet) runOnInstalledPackages(ctx context.Context, lintCtx *linter.Conte
astFiles = append(astFiles, af.F)
fset = af.Fset
}
if len(astFiles) == 0 {
continue
}
issues, err := govetAPI.Analyze(astFiles, fset, nil,
lintCtx.Settings().Govet.CheckShadowing)
if err != nil {
@ -216,6 +219,9 @@ func (g Govet) runOnSourcePackages(ctx context.Context, lintCtx *linter.Context)
// TODO: check .S asm files: govet can do it if pass dirs
var govetIssues []govetAPI.Issue
for _, pkg := range lintCtx.Program.InitialPackages() {
if len(pkg.Files) == 0 {
continue
}
issues, err := govetAPI.Analyze(pkg.Files, lintCtx.Program.Fset, pkg,
lintCtx.Settings().Govet.CheckShadowing)
if err != nil {