Denis Isaev 0421bac259 Fix #237, fix #178: use go/packages
Use go/packages instead of x/tools/loader: it allows to work
with go modules and speedups loading of packages with the help
of build cache.

A lot of linters became "fast": they are enabled by --fast now and
work in 1-2 seconds. Only unparam, interfacer and megacheck
are "slow" linters now.

Average project is analyzed 20-40% faster than before if all linters are
enabled! If we enable all linters except unparam, interfacer and
megacheck analysis is 10-20x faster!
2018-10-28 17:55:15 +03:00

29 lines
727 B
Go

package linter
import (
"github.com/golangci/golangci-lint/pkg/config"
"github.com/golangci/golangci-lint/pkg/lint/astcache"
"github.com/golangci/golangci-lint/pkg/logutils"
"github.com/golangci/tools/go/ssa"
"golang.org/x/tools/go/loader"
"golang.org/x/tools/go/packages"
)
type Context struct {
Packages []*packages.Package
NotCompilingPackages []*packages.Package
LoaderConfig *loader.Config // deprecated, don't use for new linters
Program *loader.Program // deprecated, use Packages for new linters
SSAProgram *ssa.Program
Cfg *config.Config
ASTCache *astcache.Cache
Log logutils.Log
}
func (c *Context) Settings() *config.LintersSettings {
return &c.Cfg.LintersSettings
}