Giant blob of minor changes
[dotfiles/.git] / .config / coc / extensions / coc-go-data / tools / pkg / mod / honnef.co / go / tools@v0.0.1-2020.1.5 / cmd / staticcheck / staticcheck.go
1 // staticcheck analyses Go code and makes it better.
2 package main // import "honnef.co/go/tools/cmd/staticcheck"
3
4 import (
5         "log"
6         "os"
7
8         "golang.org/x/tools/go/analysis"
9         "honnef.co/go/tools/lint"
10         "honnef.co/go/tools/lint/lintutil"
11         "honnef.co/go/tools/simple"
12         "honnef.co/go/tools/staticcheck"
13         "honnef.co/go/tools/stylecheck"
14         "honnef.co/go/tools/unused"
15 )
16
17 func main() {
18         fs := lintutil.FlagSet("staticcheck")
19         wholeProgram := fs.Bool("unused.whole-program", false, "Run unused in whole program mode")
20         debug := fs.String("debug.unused-graph", "", "Write unused's object graph to `file`")
21         fs.Parse(os.Args[1:])
22
23         var cs []*analysis.Analyzer
24         for _, v := range simple.Analyzers {
25                 cs = append(cs, v)
26         }
27         for _, v := range staticcheck.Analyzers {
28                 cs = append(cs, v)
29         }
30         for _, v := range stylecheck.Analyzers {
31                 cs = append(cs, v)
32         }
33
34         u := unused.NewChecker(*wholeProgram)
35         if *debug != "" {
36                 f, err := os.OpenFile(*debug, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0666)
37                 if err != nil {
38                         log.Fatal(err)
39                 }
40                 u.Debug = f
41         }
42         cums := []lint.CumulativeChecker{u}
43         lintutil.ProcessFlagSet(cs, cums, fs)
44 }