func Main(analyzers ...*analysis.Analyzer)
Main is the main function of a vet-like analysis tool that must be invoked by a build system to analyze a single package.
The protocol required by 'go vet -vettool=...' is that the tool must support:
-flags describe flags in JSON
-V=full describe executable for build caching
foo.cfg perform separate modular analyze on the single
unit described by a JSON config file foo.cfg.
func Run(configFile string, analyzers []*analysis.Analyzer)
Run reads the *.cfg file, runs the analysis, and calls os.Exit with an appropriate error code. It assumes flags have already been set.
A Config describes a compilation unit to be analyzed. It is provided to the tool in a JSON-encoded file whose name ends with ".cfg".
type Config struct {
ID string // e.g. "fmt [fmt.test]"
Compiler string // gc or gccgo, provided to MakeImporter
Dir string // (unused)
ImportPath string // package path
GoVersion string // minimum required Go version, such as "go1.21.0"
GoFiles []string
NonGoFiles []string
IgnoredFiles []string
ModulePath string // module path
ModuleVersion string // module version
ImportMap map[string]string // maps import path to package path
PackageFile map[string]string // maps package path to file of type information
Standard map[string]bool // package belongs to standard library
PackageVetx map[string]string // maps package path to file of fact information
VetxOnly bool // run analysis only for facts, not diagnostics
VetxOutput string // where to write file of fact information
SucceedOnTypecheckFailure bool
}