mirror of
https://github.com/scratchfoundation/golangci-lint.git
synced 2025-08-28 22:28:43 -04:00
Clear part of package fields before analysis
This commit is contained in:
parent
bb41e54b04
commit
796b4fffbe
2 changed files with 21 additions and 19 deletions
|
@ -1,6 +1,8 @@
|
|||
package linter
|
||||
|
||||
import (
|
||||
"go/ast"
|
||||
|
||||
"golang.org/x/tools/go/packages"
|
||||
|
||||
"github.com/golangci/golangci-lint/internal/pkgcache"
|
||||
|
@ -30,3 +32,18 @@ type Context struct {
|
|||
func (c *Context) Settings() *config.LintersSettings {
|
||||
return &c.Cfg.LintersSettings
|
||||
}
|
||||
|
||||
func (c *Context) ClearTypesInPackages() {
|
||||
for _, p := range c.Packages {
|
||||
clearTypes(p)
|
||||
}
|
||||
for _, p := range c.OriginalPackages {
|
||||
clearTypes(p)
|
||||
}
|
||||
}
|
||||
|
||||
func clearTypes(p *packages.Package) {
|
||||
p.Types = nil
|
||||
p.TypesInfo = nil
|
||||
p.Syntax = []*ast.File{}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue