generated from yandex-praktikum/go-musthave-shortener-tpl
/
main.go
143 lines (110 loc) · 4.32 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
// package main of staticlint provides code analyzing entrypoint
package main
import (
"github.com/DrGermanius/exitanalyser"
"github.com/go-critic/go-critic/checkers/analyzer"
"golang.org/x/tools/go/analysis"
"golang.org/x/tools/go/analysis/multichecker"
"golang.org/x/tools/go/analysis/passes/asmdecl"
"golang.org/x/tools/go/analysis/passes/assign"
"golang.org/x/tools/go/analysis/passes/atomic"
"golang.org/x/tools/go/analysis/passes/bools"
"golang.org/x/tools/go/analysis/passes/buildtag"
"golang.org/x/tools/go/analysis/passes/cgocall"
"golang.org/x/tools/go/analysis/passes/composite"
"golang.org/x/tools/go/analysis/passes/copylock"
"golang.org/x/tools/go/analysis/passes/errorsas"
"golang.org/x/tools/go/analysis/passes/framepointer"
"golang.org/x/tools/go/analysis/passes/httpresponse"
"golang.org/x/tools/go/analysis/passes/ifaceassert"
"golang.org/x/tools/go/analysis/passes/loopclosure"
"golang.org/x/tools/go/analysis/passes/lostcancel"
"golang.org/x/tools/go/analysis/passes/nilfunc"
"golang.org/x/tools/go/analysis/passes/printf"
"golang.org/x/tools/go/analysis/passes/shift"
"golang.org/x/tools/go/analysis/passes/sigchanyzer"
"golang.org/x/tools/go/analysis/passes/stdmethods"
"golang.org/x/tools/go/analysis/passes/stringintconv"
"golang.org/x/tools/go/analysis/passes/structtag"
"golang.org/x/tools/go/analysis/passes/testinggoroutine"
"golang.org/x/tools/go/analysis/passes/tests"
"golang.org/x/tools/go/analysis/passes/unmarshal"
"golang.org/x/tools/go/analysis/passes/unreachable"
"golang.org/x/tools/go/analysis/passes/unsafeptr"
"golang.org/x/tools/go/analysis/passes/unusedresult"
"honnef.co/go/tools/simple"
"honnef.co/go/tools/staticcheck"
"honnef.co/go/tools/stylecheck"
)
// main provides checkers for analyzing code using `go run main.go directory`
func main() {
var analyzers []*analysis.Analyzer
analyzers = append(analyzers, asmdecl.Analyzer,
// check for useless assignments
assign.Analyzer,
// check for common mistakes using the sync/atomic package
atomic.Analyzer,
// check for common mistakes involving boolean operators
bools.Analyzer,
// check that +build tags are well-formed and correctly located
buildtag.Analyzer,
// detect some violations of the cgo pointer passing rules
cgocall.Analyzer,
// check for unkeyed composite literals
composite.Analyzer,
// check for locks erroneously passed by value
copylock.Analyzer,
// report passing non-pointer or non-error values to errors.As
errorsas.Analyzer,
// report assembly that clobbers the frame pointer before saving it
framepointer.Analyzer,
// check for mistakes using HTTP responses
httpresponse.Analyzer,
// detect impossible interface-to-interface type assertions
ifaceassert.Analyzer,
// check references to loop variables from within nested functions
loopclosure.Analyzer,
// check cancel func returned by context.WithCancel is called
lostcancel.Analyzer,
// check for useless comparisons between functions and nil
nilfunc.Analyzer,
// check consistency of Printf format strings and arguments
printf.Analyzer,
// check for shifts that equal or exceed the width of the integer
shift.Analyzer,
// check for unbuffered channel of os.Signal
sigchanyzer.Analyzer,
// check signature of methods of well-known interfaces
stdmethods.Analyzer,
// check for string(int) conversions
stringintconv.Analyzer,
// check that struct field tags conform to reflect.StructTag.Get
structtag.Analyzer,
// check for common mistaken usages of tests and examples
tests.Analyzer,
// report calls to (*testing.T).Fatal from goroutines started by a test
testinggoroutine.Analyzer,
// report passing non-pointer or non-interface values to unmarshal
unmarshal.Analyzer,
// check for unreachable code
unreachable.Analyzer,
// check for invalid conversions of uintptr to unsafe.Pointer
unsafeptr.Analyzer,
// check for unused results of calls to some functions
unusedresult.Analyzer,
// the most opinionated Go source code linter
analyzer.Analyzer,
// check for os.Exit calls
exitanalyser.Analyzer,
)
for _, v := range simple.Analyzers {
analyzers = append(analyzers, v)
}
for _, v := range staticcheck.Analyzers {
analyzers = append(analyzers, v)
}
for _, v := range stylecheck.Analyzers {
analyzers = append(analyzers, v)
}
multichecker.Main(analyzers...)
}