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
1. Allow govet to work in 2 modes: fast and slow. Default is slow.
In fast mode golangci-lint runs `go install -i` and `go test -i`
for analyzed packages. But it's fast only when:
- go >= 1.10
- it's repeated run or $GOPATH/pkg or `go env GOCACHE` is cached
between CI builds
In slow mode we load program from source code like for another linters
and do it only once for all linters.
3. Patch govet code to warn about any troubles with the type
information. Default behaviour of govet was to hide such warnings.
Fail analysis if there are any troubles with type loading: it will
prevent false-positives and false-negatives from govet.
4. Describe almost all options in .golangci.example.yml and
include it into README. Describe when to use slow or fast mode of govet.
5. Speed up govet: reuse AST parsing: it's already parsed once by
golangci-lint.
For "slow" runs (when we run at least one slow linter) speedup by
not loading type information second time.
6. Improve logging, debug logging
Copy file name to clipboardExpand all lines: README.md
+154-3
Original file line number
Diff line number
Diff line change
@@ -84,7 +84,7 @@ GolangCI-Lint can be used with zero configuration. By default the following lint
84
84
```
85
85
$ golangci-lint linters
86
86
Enabled by default linters:
87
-
govet: Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: true]
87
+
govet: Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string [fast: false]
88
88
errcheck: Errcheck is a program for checking for unchecked errors in go programs. These unchecked errors can be critical bugs in some cases [fast: false]
89
89
staticcheck: Staticcheck is a go vet on steroids, applying a ton of static analysis checks [fast: false]
90
90
unused: Checks Go code for unused constants, variables, functions and types [fast: false]
@@ -310,10 +310,161 @@ To see which config file is being used and where it was sourced from run golangc
310
310
Config options inside the file are identical to command-line options.
311
311
You can configure specific linters' options only within the config file (not the command-line).
312
312
313
-
There is a [`.golangci.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example config file with all supported options.
313
+
There is a [`.golangci.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example
314
+
config file with all supported options, their description and default value:
315
+
```yaml
316
+
# This file contains all available configuration options
317
+
# with their default values.
318
+
319
+
# options for analysis running
320
+
run:
321
+
# default concurrency is a available CPU number
322
+
concurrency: 4
323
+
324
+
# timeout for analysis, e.g. 30s, 5m, default is 1m
325
+
deadline: 1m
326
+
327
+
# exit code when at least one issue was found, default is 1
328
+
issues-exit-code: 1
329
+
330
+
# include test files or not, default is true
331
+
tests: true
332
+
333
+
# list of build tags, all linters use it. Default is empty list.
334
+
build-tags:
335
+
- mytag
336
+
337
+
# which dirs to skip: they won't be analyzed;
338
+
# can use regexp here: generated.*, regexp is applied on full path;
339
+
# default value is empty list, but next dirs are always skipped independently
# which files to skip: they will be analyzed, but issues from them
347
+
# won't be reported. Default value is empty list, but there is
348
+
# no need to include all autogenerated files, we confidently recognize
349
+
# autogenerated files. If it's not please let us know.
350
+
skip-files:
351
+
- ".*\\.my\\.go$"
352
+
- lib/bad.go
353
+
354
+
# output configuration options
355
+
output:
356
+
# colored-line-number|line-number|json|tab|checkstyle, default is "colored-line-number"
357
+
format: colored-line-number
358
+
359
+
# print lines of code with issue, default is true
360
+
print-issued-lines: true
361
+
362
+
# print linter name in the end of issue text, default is true
363
+
print-linter-name: true
364
+
365
+
# all available settings of specific linters
366
+
linters-settings:
367
+
errcheck:
368
+
# report about not checking of errors in type assetions: `a := b.(MyStruct)`;
369
+
# default is false: such cases aren't reported by default.
370
+
check-type-assertions: false
371
+
372
+
# report about assignment of errors to blank identifier: `num, _ := strconv.Atoi(numStr)`;
373
+
# default is false: such cases aren't reported by default.
374
+
check-blank: false
375
+
govet:
376
+
# report about shadowed variables
377
+
check-shadowing: true
378
+
379
+
# Obtain type information from installed (to $GOPATH/pkg) package files:
380
+
# golangci-lint will execute `go install -i` and `go test -i` for analyzed packages
381
+
# before analyzing them.
382
+
# By default this option is disabled and govet gets type information by loader from source code.
383
+
# Loading from source code is slow, but it's done only once for all linters.
384
+
# Go-installing of packages first time is much slower than loading them from source code,
385
+
# therefore this option is disabled by default.
386
+
# But repeated installation is fast in go >= 1.10 because of build caching.
387
+
# Enable this option only if all conditions are met:
388
+
# 1. you use only "fast" linters (--fast e.g.): no program loading occurs
389
+
# 2. you use go >= 1.10
390
+
# 3. you do repeated runs (false for CI) or cache $GOPATH/pkg or `go env GOCACHE` dir in CI.
391
+
use-installed-packages: false
392
+
golint:
393
+
# minimal confidence for issues, default is 0.8
394
+
min-confidence: 0.8
395
+
gofmt:
396
+
# simplify code: gofmt with `-s` option, true by default
397
+
simplify: true
398
+
gocyclo:
399
+
# minimal code complexity to report, 30 by default (but we recommend 10-20)
400
+
min-complexity: 10
401
+
maligned:
402
+
# print struct with more effective memory layout or not, false by default
403
+
suggest-new: true
404
+
dupl:
405
+
# tokens count to trigger issue, 150 by default
406
+
threshold: 100
407
+
goconst:
408
+
# minimal length of string constant, 3 by default
409
+
min-len: 3
410
+
# minimal occurrences count to trigger, 3 by default
411
+
min-occurrences: 3
412
+
depguard:
413
+
list-type: blacklist
414
+
include-go-root: false
415
+
packages:
416
+
- github.com/davecgh/go-spew/spew
417
+
418
+
linters:
419
+
enable:
420
+
- megacheck
421
+
- govet
422
+
enable-all: false
423
+
disable:
424
+
maligned
425
+
disable-all: false
426
+
presets:
427
+
- bugs
428
+
- unused
429
+
fast: false
430
+
431
+
issues:
432
+
# List of regexps of issue texts to exclude, empty list by default.
433
+
# But independently from this option we use default exclude patterns,
434
+
# it can be disabled by `exclude-use-default: false`. To list all
435
+
# excluded by default patterns execute `golangci-lint run --help`
436
+
exclude:
437
+
- abcdef
438
+
439
+
# Independently from option `exclude` we use default exclude patterns,
440
+
# it can be disabled by this option. To list all
441
+
# excluded by default patterns execute `golangci-lint run --help`.
442
+
# Default value for this option is false.
443
+
exclude-use-default: true
444
+
445
+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
446
+
max-per-linter: 0
447
+
448
+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
449
+
max-same: 0
450
+
451
+
# Show only new issues: if there are unstaged changes or untracked files,
452
+
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
453
+
# It's a super-useful option for integration of golangci-lint into existing
454
+
# large codebase. It's not practical to fix all existing issues at the moment
455
+
# of integration: much better don't allow issues in new code.
456
+
# Default is false.
457
+
new: false
458
+
459
+
# Show only new issues created after git revision `REV`
460
+
new-from-rev: REV
461
+
462
+
# Show only new issues created in git patch with set file path.
463
+
new-from-patch: path/to/patch/file
464
+
```
314
465
315
466
It's a [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml) config file of this repo: we enable more linters
Copy file name to clipboardExpand all lines: README.md.tmpl
+6-2
Original file line number
Diff line number
Diff line change
@@ -200,10 +200,14 @@ To see which config file is being used and where it was sourced from run golangc
200
200
Config options inside the file are identical to command-line options.
201
201
You can configure specific linters' options only within the config file (not the command-line).
202
202
203
-
There is a [`.golangci.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example config file with all supported options.
203
+
There is a [`.golangci.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example
204
+
config file with all supported options, their description and default value:
205
+
```yaml
206
+
{{.GolangciYamlExample}}
207
+
```
204
208
205
209
It's a [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml) config file of this repo: we enable more linters
0 commit comments