Isaev Denis 95ec0cf21e
dramatically reduce memory usage ()
Run all linters per package. It allows unloading package data when it's
processed. It dramatically reduces memory (and CPU because of GC) usage.

Relates: 
2019-09-30 16:19:41 +03:00

37 lines
783 B
Go

package goanalysis
import (
"go/types"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/loader"
)
func MakeFakeLoaderProgram(pass *analysis.Pass) *loader.Program {
prog := &loader.Program{
Fset: pass.Fset,
Created: []*loader.PackageInfo{
{
Pkg: pass.Pkg,
Importable: true, // not used
TransitivelyErrorFree: true, // TODO
Files: pass.Files,
Errors: nil,
Info: *pass.TypesInfo,
},
},
AllPackages: map[*types.Package]*loader.PackageInfo{
pass.Pkg: {
Pkg: pass.Pkg,
Importable: true,
TransitivelyErrorFree: true,
Files: pass.Files,
Errors: nil,
Info: *pass.TypesInfo,
},
},
}
return prog
}