Skip to content

Commit 3d426c7

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

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

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)