Skip to content

Commit

Permalink
fix invalid error message "no go files to analyze"
Browse files Browse the repository at this point in the history
In case of timeouts of go/packages loading
we could return such error.

Relates: #825
  • Loading branch information
jirfag committed May 18, 2020
1 parent cd34a1e commit aa8137f
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions pkg/lint/load.go
Expand Up @@ -199,7 +199,14 @@ func (cl *ContextLoader) loadPackages(ctx context.Context, loadMode packages.Loa
cl.debugf("Built loader args are %s", args)
pkgs, err := packages.Load(conf, args...)
if err != nil {
return nil, errors.Wrap(err, "failed to load program with go/packages")
return nil, errors.Wrap(err, "failed to load with go/packages")
}

// Currently, go/packages doesn't guarantee that error will be returned
// if context was cancelled. See
// https://github.com/golang/tools/commit/c5cec6710e927457c3c29d6c156415e8539a5111#r39261855
if ctx.Err() != nil {
return nil, errors.Wrap(ctx.Err(), "timeouted to load packages")
}

if loadMode&packages.NeedSyntax == 0 {
Expand Down Expand Up @@ -280,7 +287,7 @@ func (cl *ContextLoader) Load(ctx context.Context, linters []*linter.Config) (*l
loadMode := cl.findLoadMode(linters)
pkgs, err := cl.loadPackages(ctx, loadMode)
if err != nil {
return nil, err
return nil, errors.Wrap(err, "failed to load packages")
}

deduplicatedPkgs := cl.filterDuplicatePackages(pkgs)
Expand Down

0 comments on commit aa8137f

Please sign in to comment.