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
7. Fix crash in logging of AST cache warnings (#118)
Copy file name to clipboardExpand all lines: README.md
+158-7Lines changed: 158 additions & 7 deletions
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]
@@ -311,10 +311,161 @@ To see which config file is being used and where it was sourced from run golangc
311
311
Config options inside the file are identical to command-line options.
312
312
You can configure specific linters' options only within the config file (not the command-line).
313
313
314
-
There is a [`.golangci.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example config file with all supported options.
314
+
There is a [`.golangci.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example
315
+
config file with all supported options, their description and default value:
316
+
```yaml
317
+
# This file contains all available configuration options
318
+
# with their default values.
319
+
320
+
# options for analysis running
321
+
run:
322
+
# default concurrency is a available CPU number
323
+
concurrency: 4
324
+
325
+
# timeout for analysis, e.g. 30s, 5m, default is 1m
326
+
deadline: 1m
327
+
328
+
# exit code when at least one issue was found, default is 1
329
+
issues-exit-code: 1
330
+
331
+
# include test files or not, default is true
332
+
tests: true
333
+
334
+
# list of build tags, all linters use it. Default is empty list.
335
+
build-tags:
336
+
- mytag
337
+
338
+
# which dirs to skip: they won't be analyzed;
339
+
# can use regexp here: generated.*, regexp is applied on full path;
340
+
# default value is empty list, but next dirs are always skipped independently
# List of regexps of issue texts to exclude, empty list by default.
434
+
# But independently from this option we use default exclude patterns,
435
+
# it can be disabled by `exclude-use-default: false`. To list all
436
+
# excluded by default patterns execute `golangci-lint run --help`
437
+
exclude:
438
+
- abcdef
439
+
440
+
# Independently from option `exclude` we use default exclude patterns,
441
+
# it can be disabled by this option. To list all
442
+
# excluded by default patterns execute `golangci-lint run --help`.
443
+
# Default value for this option is false.
444
+
exclude-use-default: true
445
+
446
+
# Maximum issues count per one linter. Set to 0 to disable. Default is 50.
447
+
max-per-linter: 0
448
+
449
+
# Maximum count of issues with the same text. Set to 0 to disable. Default is 3.
450
+
max-same: 0
451
+
452
+
# Show only new issues: if there are unstaged changes or untracked files,
453
+
# only those changes are analyzed, else only changes in HEAD~ are analyzed.
454
+
# It's a super-useful option for integration of golangci-lint into existing
455
+
# large codebase. It's not practical to fix all existing issues at the moment
456
+
# of integration: much better don't allow issues in new code.
457
+
# Default is false.
458
+
new: false
459
+
460
+
# Show only new issues created after git revision `REV`
461
+
new-from-rev: REV
462
+
463
+
# Show only new issues created in git patch with set file path.
464
+
new-from-patch: path/to/patch/file
465
+
```
315
466
316
467
It's a [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml) config file of this repo: we enable more linters
317
-
than the default and more strict settings:
468
+
than the default and have more strict settings:
318
469
```yaml
319
470
linters-settings:
320
471
govet:
@@ -410,11 +561,11 @@ go install ./vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/
410
561
```
411
562
Vendoring `golangci-lint` saves a network request, potentially making your CI system a little more reliable.
412
563
413
-
**`govet` or `golint` reports false-positives or false-negatives**
564
+
**Does I need to run `go install`?**
414
565
415
-
These linters obtain type information from installed package files.
416
-
The same issue you will encounter if will run `govet` or `golint` without `golangci-lint`.
417
-
Try `go install ./...` (or `go install ./cmd/...`: depends on the project) first.
566
+
No, you don't need to do it anymore. We will run `go install -i` and `go test -i`
567
+
for analyzed packages ourselves. We will run them only
568
+
if option `govet.use-installed-packages` is `true`.
Copy file name to clipboardExpand all lines: README.md.tmpl
+10-6Lines changed: 10 additions & 6 deletions
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
206
-
than the default and more strict settings:
210
+
than the default and have more strict settings:
207
211
```yaml
208
212
{{.GolangciYaml}}
209
213
```
@@ -275,11 +279,11 @@ go install ./vendor/github.com/golangci/golangci-lint/cmd/golangci-lint/
275
279
```
276
280
Vendoring `golangci-lint` saves a network request, potentially making your CI system a little more reliable.
277
281
278
-
**`govet` or `golint` reports false-positives or false-negatives**
282
+
**Does I need to run `go install`?**
279
283
280
-
These linters obtain type information from installed package files.
281
-
The same issue you will encounter if will run `govet` or `golint` without `golangci-lint`.
282
-
Try `go install ./...` (or `go install ./cmd/...`: depends on the project) first.
284
+
No, you don't need to do it anymore. We will run `go install -i` and `go test -i`
285
+
for analyzed packages ourselves. We will run them only
286
+
if option `govet.use-installed-packages` is `true`.
0 commit comments