You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+72-96Lines changed: 72 additions & 96 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -134,7 +134,10 @@ This issue is important because often you'd like to set concurrency to CPUs coun
134
134
3. It will take more time because of different usages and need of tracking of versions of `n` linters.
135
135
136
136
# Performance
137
-
Benchmarks were executed on MacBook Pro (Retina, 13-inch, Late 2013), 2,4 GHz Intel Core i5, 8 GB 1600 MHz DDR3. It has 4 cores and concurrency for linters was default: number of cores. Benchmark runs and measures timings automatically, it's code is [here](https://github.com/golangci/golangci-lint/blob/master/test/bench.go) (`BenchmarkWithGometalinter`).
137
+
Benchmarks were executed on MacBook Pro (Retina, 13-inch, Late 2013), 2,4 GHz Intel Core i5, 8 GB 1600 MHz DDR3.
138
+
It has 4 cores and concurrency for linters was default: number of cores.
139
+
Benchmark runs and measures timings automatically, it's code is
We measure peak memory usage (RSS) by tracking of processes RSS every 5 ms.
140
143
@@ -172,7 +175,7 @@ On average golangci-lint consumes 1.35 times less memory.
172
175
173
176
# Supported Linters
174
177
To see a list of supported linters and which linters are enabled/disabled by default execute a command
175
-
```bash
178
+
```
176
179
golangci-lint linters
177
180
```
178
181
@@ -204,98 +207,76 @@ golangci-lint linters
204
207
205
208
# Configuration
206
209
## Command-Line Options
207
-
Run next command to see their description and defaults.
208
-
```bash
209
-
golangci-lint run -h
210
210
```
211
+
golangci-lint run -h
212
+
Usage:
213
+
golangci-lint run [flags]
214
+
215
+
Flags:
216
+
--out-format string Format of output: colored-line-number|line-number|json (default "colored-line-number")
217
+
--print-issued-lines Print lines of code with issue (default true)
218
+
--print-linter-name Print linter name in issue line (default true)
219
+
--issues-exit-code int Exit code when issues were found (default 1)
220
+
--build-tags strings Build tags (not all linters support them)
221
+
--deadline duration Deadline for total work (default 1m0s)
222
+
--tests Analyze tests (*_test.go)
223
+
--print-resources-usage Print avg and max memory usage of golangci-lint and total time
224
+
-c, --config PATH Read config from file path PATH
225
+
--no-config Don't read config
226
+
-E, --enable strings Enable specific linter
227
+
-D, --disable strings Disable specific linter
228
+
--enable-all Enable all linters
229
+
--disable-all Disable all linters
230
+
-p, --presets strings Enable presets (bugs|unused|format|style|complexity|performance) of linters. Run 'golangci-lint linters' to see them. This option implies option --disable-all
231
+
--fast Run only fast linters from enabled linters set
232
+
-e, --exclude strings Exclude issue by regexp
233
+
--exclude-use-default Use or not use default excludes:
234
+
# errcheck: Almost all programs ignore errors on these functions and in most cases it's ok
235
+
- Error return value of .((os\.)?std(out|err)\..*|.*Close|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked
236
+
237
+
# golint: Annoying issue about not having a comment. The rare codebase has such comments
238
+
- (should have comment|comment on exported method|should have a package comment)
239
+
240
+
# golint: False positive when tests are defined in package 'test'
241
+
- func name will be used as test\.Test.* by other packages, and that stutters; consider calling this
242
+
243
+
# gas: Too many false-positives on 'unsafe' usage
244
+
- Use of unsafe calls should be audited
245
+
246
+
# gas: Too many false-positives for parametrized shell calls
247
+
- Subprocess launch(ed with variable|ing should be audited)
248
+
249
+
# gas: Duplicated errcheck checks
250
+
- G104
251
+
252
+
# gas: Too many issues in popular repos
253
+
- (Expect directory permissions to be 0750 or less|Expect file permissions to be 0600 or less)
254
+
255
+
# gas: False positive is triggered by 'src, err := ioutil.ReadFile(filename)'
256
+
- Potential file inclusion via variable
257
+
258
+
# govet: Common false positives
259
+
- (possible misuse of unsafe.Pointer|should have signature)
260
+
261
+
# megacheck: Developers tend to write in C-style with an explicit 'break' in a 'switch', so it's ok to ignore
262
+
- ineffective break statement. Did you mean to break out of the outer loop
263
+
(default true)
264
+
--max-issues-per-linter int Maximum issues count per one linter. Set to 0 to disable (default 50)
265
+
--max-same-issues int Maximum count of issues with the same text. Set to 0 to disable (default 3)
266
+
-n, --new Show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed.
267
+
It's a super-useful option for integration of golangci-lint into existing large codebase.
268
+
It's not practical to fix all existing issues at the moment of integration: much better don't allow issues in new code
269
+
--new-from-rev REV Show only new issues created after git revision REV
270
+
--new-from-patch PATH Show only new issues created in git patch with file path PATH
271
+
-h, --help help for run
272
+
273
+
Global Flags:
274
+
-j, --concurrency int Concurrency (default NumCPU) (default 8)
275
+
--cpu-profile-path string Path to CPU profile output file
276
+
--mem-profile-path string Path to memory profile output file
277
+
-v, --verbose verbose output
211
278
212
-
### Run Options
213
-
-`-c, --config` - path to [config file](#configuration-file) if you don't like using default config path `.golangci.(yml|toml|json)`.
214
-
-`-j, --concurrency` - the number of threads used. By default, it's a number of CPUs. Unlike `gometalinter`, it's an honest value, since we do not fork linter processes.
215
-
-`--build-tags` - build tags to take into account.
216
-
-`--issues-exit-code` - exit code if issues were found. The default is `1`.
217
-
-`--deadline` - timeout for running golangci-lint, `1m` by default.
218
-
-`--tests` - analyze `*_test.go` files. It's `false` by default.
219
-
-`-v, --verbose` - enable verbose output. Use this options to see which linters were enabled, to see timings of steps and another helpful information.
220
-
-`--print-resources-usage` - print memory usage and total time elapsed.
221
-
222
-
### Linters
223
-
-`-E, --enable` - enable specific linter. You can pass option multiple times or use a comma:
224
-
```bash
225
-
golangci-lint run --disable-all -E golint -E govet -E errcheck
226
-
golangci-lint run --disable-all --enable golint,govet,errcheck
227
-
```
228
-
-`-D, --disable` - disable specific linter. Similar to enabling option.
229
-
-`--enable-all` - enable all supported linters.
230
-
-`--disable-all` - disable all supported linters.
231
-
-`-p, --presets` - enable specific presets. To list all presets run
$ golangci-lint run -v --disable-all -p bugs,style,complexity,format
246
-
INFO[0000] Active linters: [govet goconst gocyclo gofmt gas dupl goimports megacheck interfacer unconvert errcheck golint]
247
279
```
248
-
-`--fast` - run only fast linters from the enabled set of linters. To find out which linters are fast run `golangci-lint linters`.
249
-
250
-
### Linters Options
251
-
-`--errcheck.check-type-assertions` - errcheck: check for ignored type assertion results. Disabled by default.
252
-
-`--errcheck.check-blank` - errcheck: check for errors assigned to blank identifier: `_ = errFunc()`. Disabled by default
253
-
-`--govet.check-shadowing` - govet: check for shadowed variables. Disabled by default.
254
-
-`--golint.min-confidence` - golint: minimum confidence of a problem to print it. The default is `0.8`.
255
-
-`--gofmt.simplify` - gofmt: simplify code (`gofmt -s`), enabled by default.
256
-
-`--gocyclo.min-complexity` - gocyclo: a minimal complexity of function to report it. The default is `30` (it's very high limit).
257
-
-`--maligned.suggest-new` - Maligned: print suggested more optimal struct fields ordering. Disabled by default. Example:
258
-
```
259
-
crypto/tls/ticket.go:20: struct of size 64 bytes could be of size 56 bytes:
260
-
struct{
261
-
masterSecret []byte,
262
-
certificates [][]byte,
263
-
vers uint16,
264
-
cipherSuite uint16,
265
-
usedOldKey bool,
266
-
}
267
-
```
268
-
-`--dupl.threshold` - dupl: Minimal threshold to detect copy-paste, `150` by default.
269
-
-`--goconst.min-len` - goconst: minimum constant string length, `3` by default.
270
-
-`--goconst.min-occurrences` - goconst: minimum occurences of constant string count to trigger issue. Default is `3`.
271
-
272
-
### Issues Options
273
-
-`-n, --new` - show only new issues: if there are unstaged changes or untracked files, only those changes are analyzed, else only changes in HEAD~ are analyzed. It's a super-useful option for integration `golangci-lint` into existing large codebase. It's not practical to fix all existing issues at the moment of integration: much better don't allow issues in new code. Disabled by default.
274
-
-`--new-from-rev` - show only new issues created after specified git revision.
275
-
-`--new-from-patch` - show only new issues created in git patch with the specified file path.
276
-
-`-e, --exclude` - exclude issue by regexp on issue text.
277
-
-`--exclude-use-default` - use or not use default excludes. We tested our linter on large codebases and marked common false positives. By default we ignore common false positives by next regexps:
278
-
-`Error return value of .((os\.)?std(out|err)\..*|.*Close|os\.Remove(All)?|.*printf?|os\.(Un)?Setenv). is not checked` - ercheck: almost all programs ignore errors on these functions and in most cases it's ok.
279
-
-`(should have comment|comment on exported method)` - golint: annoying issues about not having a comment. The rare codebase has such comments.
280
-
-`G103:` - gas: `Use of unsafe calls should be audited`
281
-
-`G104:` - gas: `disable what errcheck does: it reports on Close etc`
282
-
-`G204:` - gas: `Subprocess launching should be audited: too lot false - positives`
283
-
-`G301:` - gas: `Expect directory permissions to be 0750 or less`
284
-
-`G302:` - gas: `Expect file permissions to be 0600 or less`
-`(possible misuse of unsafe.Pointer|should have signature)` - common false positives by govet.
288
-
-`ineffective break statement. Did you mean to break out of the outer loop` - megacheck: developers tend to write in C-style with an explicit `break` in a switch, so it's ok to ignore.
289
-
290
-
Use option `--exclude-use-default=false` to disable these default exclude regexps.
291
-
-`--max-issues-per-linter` - maximum issues count per one linter. Set to `0` to disable. The default value is `50` to not being annoying.
292
-
-`--max-same-issues` - maximum count of issues with the same text. Set to 0 to disable. The default value is `3` to not being annoying.
293
-
294
-
### Output Options
295
-
-`--out-format` - format of output: `colored-line-number|line-number|json`, default is `colored-line-number`.
296
-
-`--print-issued-lines` - print line of source code where the issue occurred. Enabled by default.
297
-
-`--print-linter-name` - print linter name in issue line. Enabled by default.
298
-
-`--print-welcome` - print welcome message. Enabled by default.
299
280
300
281
## Configuration File
301
282
GolangCI-Lint looks for next config paths in the current directory:
0 commit comments