func Run(configFile string, analyzers []*analysis.Analyzer) {
	cfg, err := readConfig(configFile)
	if err != nil {
		log.Fatal(err)
	}

	fset := token.NewFileSet()
	results, err := run(fset, cfg, analyzers)
	if err != nil {
		log.Fatal(err)
	}

	// In VetxOnly mode, the analysis is run only for facts.
	if !cfg.VetxOnly {
		if analysisflags.JSON {
			// JSON output
			tree := make(analysisflags.JSONTree)
			for _, res := range results {
				tree.Add(fset, cfg.ID, res.a.Name, res.diagnostics, res.err)
			}
			tree.Print()
		} else {
			// plain text
			exit := 0
			for _, res := range results {
				if res.err != nil {
					log.Println(res.err)
					exit = 1
				}
			}
			for _, res := range results {
				for _, diag := range res.diagnostics {
					analysisflags.PrintPlain(fset, diag)
					exit = 1
				}
			}
			os.Exit(exit)
		}
	}

	os.Exit(0)
}
// Run reads the *.cfg file, runs the analysis,
// and calls os.Exit with an appropriate error code.
// It assumes flags have already been set.
Run reads the *.cfg file, runs the analysis,
and calls os.Exit with an appropriate error code.
It assumes flags have already been set.
// Run reads the * . cfg file runs the analysis // and calls os . Exit with an appropriate error code . // It assumes flags have already been set .
func Run(configFile string, analyzers []*analysis.Analyzer) {
	cfg, err := readConfig(configFile)
	if err != nil {
		log.Fatal(err)
	}
	fset := token.NewFileSet()
	results, err := run(fset, cfg, analyzers)
	if err != nil {
		log.Fatal(err)
	}
	if !cfg.VetxOnly {
		if analysisflags.JSON {
			tree := make(analysisflags.JSONTree)
			for _, res := range results {
				tree.Add(fset, cfg.ID, res.a.Name, res.diagnostics, res.err)
			}
			tree.Print()
		} else {
			exit := 0
			for _, res := range results {
				if res.err != nil {
					log.Println(res.err)
					exit = 1
				}
			}
			for _, res := range results {
				for _, diag := range res.diagnostics {
					analysisflags.PrintPlain(fset, diag)
					exit = 1
				}
			}
			os.Exit(exit)
		}
	}
	os.Exit(0)
}
func Run ( configFile string , analyzers [ ] * analysis . Analyzer ) { cfg , err := readConfig ( configFile ) if err != nil { log . Fatal ( err ) } fset := token . NewFileSet ( ) results , err := run ( fset , cfg , analyzers ) if err != nil { log . Fatal ( err ) } if ! cfg . VetxOnly { if analysisflags . JSON { tree := make ( analysisflags . JSONTree ) for _ , res := range results { tree . Add ( fset , cfg . ID , res . a . Name , res . diagnostics , res . err ) } tree . Print ( ) } else { exit := 0 for _ , res := range results { if res . err != nil { log . Println ( res . err ) exit = 1 } } for _ , res := range results { for _ , diag := range res . diagnostics { analysisflags . PrintPlain ( fset , diag ) exit = 1 } } os . Exit ( exit ) } } os . Exit ( 0 ) }
Run reads the *.cfg file, runs the analysis,
and calls os.Exit with an appropriate error code.
Run reads the * . cfg file runs the analysis and calls os . Exit with an appropriate error code .
// In VetxOnly mode, the analysis is run only for facts. // JSON output // plain text