github.com/be-b10g/golangci-lint@v1.17.2/README.tmpl.md (about) 1 # GolangCI-Lint 2 3 [![Build Status](https://travis-ci.com/golangci/golangci-lint.svg?branch=master)](https://travis-ci.com/golangci/golangci-lint) 4 [![GolangCI](https://golangci.com/badges/github.com/golangci/golangci-lint.svg)](https://golangci.com) 5 6 GolangCI-Lint is a linters aggregator. It's fast: on average [5 times faster](#performance) than gometalinter. 7 It's [easy to integrate and use](#command-line-options), has [nice output](#quick-start) and has a minimum number of false positives. It supports go modules. 8 9 GolangCI-Lint has [integrations](#editor-integration) with VS Code, GNU Emacs, Sublime Text. 10 11 Follow the news and releases on our [twitter](https://twitter.com/golangci) and our [blog](https://medium.com/golangci). 12 13 Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running linters on Github pull requests. Free for Open Source. 14 15 <a href="https://golangci.com/"><img src="docs/go.png" width="250px"></a> 16 17 * [Demo](#demo) 18 * [Install](#install) 19 * [Trusted By](#trusted-by) 20 * [Quick Start](#quick-start) 21 * [Editor Integration](#editor-integration) 22 * [Comparison](#comparison) 23 * [Performance](#performance) 24 * [Internals](#internals) 25 * [Supported Linters](#supported-linters) 26 * [Configuration](#configuration) 27 * [False Positives](#false-positives) 28 * [FAQ](#faq) 29 * [Thanks](#thanks) 30 * [Changelog](#changelog) 31 * [Future Plans](#future-plans) 32 * [Contact Information](#contact-information) 33 34 ## Demo 35 36 <p align="center"> 37 <img src="./docs/demo.svg" width="100%"> 38 </p> 39 40 Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego). 41 [![asciicast](https://asciinema.org/a/183662.png)](https://asciinema.org/a/183662) 42 43 ## Install 44 45 ### CI Installation 46 47 Most installations are done for CI (travis, circleci etc). It's important to have reproducible CI: 48 don't start to fail all builds at the same time. With golangci-lint this can happen if you 49 use `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded. 50 51 It's highly recommended to install a fixed version of golangci-lint. 52 Releases are available on the [releases page](https://github.com/golangci/golangci-lint/releases). 53 54 The recommended way to install golangci-lint (replace `vX.Y.Z` with the latest 55 version from the [releases page](https://github.com/golangci/golangci-lint/releases)): 56 57 ```bash 58 # binary will be $(go env GOPATH)/bin/golangci-lint 59 curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin vX.Y.Z 60 61 # or install it into ./bin/ 62 curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z 63 64 # In alpine linux (as it does not come with curl by default) 65 wget -O - -q https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s vX.Y.Z 66 67 golangci-lint --version 68 ``` 69 70 As a fallback you can also use `raw.githubusercontent.com` 71 72 ```bash 73 # binary will be $(go env GOPATH)/bin/golangci-lint 74 curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z 75 76 # or install it into ./bin/ 77 curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z 78 79 # In alpine linux (as it does not come with curl by default) 80 wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z 81 82 golangci-lint --version 83 ``` 84 85 Periodically update version of golangci-lint: the project is under active development 86 and is constantly being improved. But please always check for newly found issues and 87 update if needed. 88 89 ### Local Installation 90 91 Local installation is not recommended for your CI pipeline. Only install the linter this way in a local development environment. 92 93 #### Windows, MacOS and Linux 94 95 ```bash 96 go get -u github.com/golangci/golangci-lint/cmd/golangci-lint 97 ``` 98 99 With `go1.11` or later you can get a particular version 100 101 ```bash 102 GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.17.1 103 ``` 104 105 #### MacOS 106 107 You can also install it on MacOS using [brew](https://brew.sh/): 108 109 ```bash 110 brew install golangci/tap/golangci-lint 111 brew upgrade golangci/tap/golangci-lint 112 ``` 113 114 #### `--version` 115 116 If you need your local `golangci-lint --version` to show proper version additionally run: 117 118 ```bash 119 cd $(go env GOPATH)/src/github.com/golangci/golangci-lint/cmd/golangci-lint 120 go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'" 121 ``` 122 123 On Windows, you can run the above commands with Git Bash, which comes with [Git for Windows](https://git-scm.com/download/win). 124 125 ## Trusted By 126 127 The following companies/products use golangci-lint: 128 129 * [Google](https://github.com/GoogleContainerTools/skaffold) 130 * [Facebook](https://github.com/facebookincubator/fbender) 131 * [Red Hat OpenShift](https://github.com/openshift/telemeter) 132 * [Yahoo](https://github.com/yahoo/yfuzz) 133 * [IBM](https://github.com/ibm-developer/ibm-cloud-env-golang) 134 * [Xiaomi](https://github.com/XiaoMi/soar) 135 * [Samsung](https://github.com/samsung-cnct/cluster-api-provider-ssh) 136 * [Arduino](https://github.com/arduino/arduino-cli) 137 * [Eclipse Foundation](https://github.com/eclipse/che-go-jsonrpc) 138 * [WooCart](https://github.com/woocart/gsutil) 139 * [Percona](https://github.com/percona/pmm-managed) 140 * [Serverless](https://github.com/serverless/event-gateway) 141 * [ScyllaDB](https://github.com/scylladb/gocqlx) 142 * [NixOS](https://github.com/NixOS/nixpkgs-channels) 143 * [The New York Times](https://github.com/NYTimes/encoding-wrapper) 144 * [Istio](https://github.com/istio/istio) 145 146 The following great projects use golangci-lint: 147 148 * [goreleaser/goreleaser](https://github.com/goreleaser/goreleaser) 149 * [tsuru/tsuru](https://github.com/tsuru/tsuru) 150 * [xenolf/lego](https://github.com/xenolf/lego) 151 * [go-swagger/go-swagger](https://github.com/go-swagger/go-swagger) 152 * [kubernetes-sigs/kustomize](https://github.com/kubernetes-sigs/kustomize) 153 * [virtual-kubelet/virtual-kubelet](https://github.com/virtual-kubelet/virtual-kubelet) 154 * [alecthomas/participle](https://github.com/alecthomas/participle) 155 * [asobti/kube-monkey](https://github.com/asobti/kube-monkey) 156 * [getantibody/antibody](https://github.com/getantibody/antibody) 157 * [banzaicloud/pipeline](https://github.com/banzaicloud/pipeline) 158 * [posener/complete](https://github.com/posener/complete) 159 * [y0ssar1an/q](https://github.com/y0ssar1an/q) 160 * [segmentio/terraform-docs](https://github.com/segmentio/terraform-docs) 161 162 ## Quick Start 163 164 To run golangci-lint execute: 165 166 ```bash 167 golangci-lint run 168 ``` 169 170 It's an equivalent of executing: 171 172 ```bash 173 golangci-lint run ./... 174 ``` 175 176 You can choose which directories and files to analyze: 177 178 ```bash 179 golangci-lint run dir1 dir2/... dir3/file1.go 180 ``` 181 182 Directories are NOT analyzed recursively. To analyze them recursively append `/...` to their path. 183 184 GolangCI-Lint can be used with zero configuration. By default the following linters are enabled: 185 186 ```bash 187 $ golangci-lint help linters 188 {{.LintersCommandOutputEnabledOnly}} 189 ``` 190 191 and the following linters are disabled by default: 192 193 ```bash 194 $ golangci-lint help linters 195 ... 196 {{.LintersCommandOutputDisabledOnly}} 197 ``` 198 199 Pass `-E/--enable` to enable linter and `-D/--disable` to disable: 200 201 ```bash 202 golangci-lint run --disable-all -E errcheck 203 ``` 204 205 ## Editor Integration 206 207 1. [Go for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go). 208 Recommended settings for VS Code are: 209 210 ```json 211 "go.lintTool":"golangci-lint", 212 "go.lintFlags": [ 213 "--fast" 214 ] 215 ``` 216 217 Using it in an editor without `--fast` can freeze your editor. 218 Golangci-lint automatically discovers `.golangci.yml` config for edited file: you don't need to configure it in VS Code settings. 219 2. Sublime Text - [plugin](https://github.com/alecthomas/SublimeLinter-contrib-golang-cilint) for SublimeLinter. 220 3. GoLand 221 * Configure [File Watcher](https://www.jetbrains.com/help/go/settings-tools-file-watchers.html) with arguments `run --print-issued-lines=false $FileDir$`. 222 * Predefined File Watcher will be added in [issue](https://youtrack.jetbrains.com/issue/GO-4574). 223 4. GNU Emacs 224 * [Spacemacs](https://github.com/syl20bnr/spacemacs/blob/develop/layers/+lang/go/README.org#pre-requisites) 225 * [flycheck checker](https://github.com/weijiangan/flycheck-golangci-lint). 226 5. Vim 227 * [vim-go](https://github.com/fatih/vim-go) 228 * syntastic [merged pull request](https://github.com/vim-syntastic/syntastic/pull/2190) with golangci-lint support 229 * ale [merged pull request](https://github.com/w0rp/ale/pull/1890) with golangci-lint support 230 6. Atom - [go-plus](https://atom.io/packages/go-plus) supports golangci-lint. 231 232 ## Comparison 233 234 ### `golangci-lint` vs `gometalinter` 235 236 GolangCI-Lint was created to fix the following issues with `gometalinter`: 237 238 1. Slow work: `gometalinter` usually works for minutes in average projects. 239 **GolangCI-Lint works [2-7x times faster](#performance)** by [reusing work](#internals). 240 2. Huge memory consumption: parallel linters don't share the same program representation and can consume 241 `n` times more memory (`n` - concurrency). GolangCI-Lint fixes it by sharing representation and **consumes 26% less memory**. 242 3. Doesn't use real bounded concurrency: if you set it to `n` it can take up to `n*n` threads because of 243 forced threads in specific linters. `gometalinter` can't do anything about it because it runs linters as 244 black boxes in forked processes. In GolangCI-Lint we run all linters in one process and completely control 245 them. Configured concurrency will be correctly bounded. 246 This issue is important because you often want to set concurrency to the CPUs count minus one to 247 ensure you **do not freeze your PC** and be able to work on it while analyzing code. 248 4. Lack of nice output. We like how the `gcc` and `clang` compilers format their warnings: **using colors, 249 printing warning lines and showing the position in line**. 250 5. Too many issues. GolangCI-Lint cuts a lot of issues by using default exclude list of common false-positives. 251 By default, it has enabled **smart issues processing**: merge multiple issues for one line, merge issues with the 252 same text or from the same linter. All of these smart processors can be configured by the user. 253 6. Integration into large codebases. A good way to start using linters in a large project is not to fix a plethora 254 of existing issues, but to set up CI and **fix only issues in new commits**. You can use `revgrep` for it, but it's 255 yet another utility to install and configure. With `golangci-lint` it's much easier: `revgrep` is already built into 256 `golangci-lint` and you can use it with one option (`-n, --new` or `--new-from-rev`). 257 7. Installation. With `gometalinter`, you need to run a linters installation step. It's easy to forget this step and 258 end up with stale linters. It also complicates CI setup. GolangCI-Lint requires **no installation of linters**. 259 8. **Yaml or toml config**. Gometalinter's JSON isn't convenient for config files. 260 261 ### `golangci-lint` vs Running Linters Manually 262 263 1. It will be much slower because `golangci-lint` runs all linters in parallel and shares 50-80% of linters work. 264 2. It will have less control and more false-positives: some linters can't be properly configured without hacks. 265 3. It will take more time because of different usages and need of tracking of versions of `n` linters. 266 267 ## Performance 268 269 Benchmarks were executed on MacBook Pro (Retina, 13-inch, Late 2013), 2,4 GHz Intel Core i5, 8 GB 1600 MHz DDR3. 270 It has 4 cores and concurrent linting as a default consuming all cores. 271 Benchmark was run (and measured) automatically, see the code 272 [here](https://github.com/golangci/golangci-lint/blob/master/test/bench_test.go) (`BenchmarkWithGometalinter`). 273 274 We measure peak memory usage (RSS) by tracking of processes RSS every 5 ms. 275 276 ### Comparison with gometalinter 277 278 We compare golangci-lint and gometalinter in default mode, but explicitly enable all linters because of small differences in the default configuration. 279 280 ```bash 281 $ golangci-lint run --no-config --issues-exit-code=0 --deadline=30m \ 282 --disable-all --enable=deadcode --enable=gocyclo --enable=golint --enable=varcheck \ 283 --enable=structcheck --enable=maligned --enable=errcheck --enable=dupl --enable=ineffassign \ 284 --enable=interfacer --enable=unconvert --enable=goconst --enable=gosec --enable=megacheck 285 $ gometalinter --deadline=30m --vendor --cyclo-over=30 --dupl-threshold=150 \ 286 --exclude=<default golangci-lint excludes> --skip=testdata --skip=builtin \ 287 --disable-all --enable=deadcode --enable=gocyclo --enable=golint --enable=varcheck \ 288 --enable=structcheck --enable=maligned --enable=errcheck --enable=dupl --enable=ineffassign \ 289 --enable=interfacer --enable=unconvert --enable=goconst --enable=gosec --enable=megacheck 290 ./... 291 ``` 292 293 | Repository | GolangCI Time | GolangCI Is Faster than Gometalinter | GolangCI Memory | GolangCI eats less memory than Gometalinter | 294 | ---------- | ------------- | ------------------------------------ | --------------- | ------------------------------------------- | 295 | gometalinter repo, 4 kLoC | 6s | **6.4x** | 0.7GB | 33% | 296 | self-repo, 4 kLoC | 12s | **7.5x** | 1.2GB | 41% | 297 | beego, 50 kLoC | 10s | **4.2x** | 1.4GB | 9% | 298 | hugo, 70 kLoC | 15s | **6.1x** | 1.6GB | 44% | 299 | consul, 127 kLoC | 58s | **4x** | 2.7GB | 41% | 300 | terraform, 190 kLoC | 2m13s | **1.6x** | 4.8GB | 0% | 301 | go-ethereum, 250 kLoC | 33s | **5x** | 3.6GB | 0% | 302 | go source (`$GOROOT/src`), 1300 kLoC | 2m45s | **2x** | 4.7GB | 0% | 303 304 **On average golangci-lint is 4.6 times faster** than gometalinter. Maximum difference is in the 305 self-repo: **7.5 times faster**, minimum difference is in terraform source code repo: 1.8 times faster. 306 307 On average golangci-lint consumes 26% less memory. 308 309 ### Why golangci-lint is faster 310 311 Golangci-lint directly calls linters (no forking) and reuses 80% of work by parsing program only once. 312 Read [this section](#internals) for details. 313 314 ### Memory Usage of Golangci-lint 315 316 A trade-off between memory usage and execution time can be controlled by [`GOGC`](https://golang.org/pkg/runtime/#hdr-Environment_Variables) environment variable. 317 Less `GOGC` values trigger garbage collection more frequently and golangci-lint consumes less memory and more CPU. Below is the trade-off table for running on this repo: 318 319 |`GOGC`|Peak Memory, GB|Executon Time, s| 320 |------|---------------|----------------| 321 |`5` |1.1 |60 | 322 |`10` |1.1 |34 | 323 |`20` |1.3 |25 | 324 |`30` |1.6 |20.2 | 325 |`50` |2.0 |17.1 | 326 |`80` |2.2 |14.1 | 327 |`100` (default)|2.2 |13.8 | 328 |`off` |3.2 |9.3 | 329 330 ## Internals 331 332 1. Work sharing 333 The key difference with gometalinter is that golangci-lint shares work between specific linters (golint, govet, ...). 334 We don't fork to call specific linter but use its API. 335 For small and medium projects 50-90% of work between linters can be reused. 336 337 * load `[]*packages.Package` by `go/packages` once 338 339 We load program (parsing all files and type-checking) only once for all linters. For the most of linters 340 it's the most heavy operation: it takes 5 seconds on 8 kLoC repo and 11 seconds on `$GOROOT/src`. 341 * build `ssa.Program` once 342 343 Some linters (megacheck, interfacer, unparam) work on SSA representation. 344 Building of this representation takes 1.5 seconds on 8 kLoC repo and 6 seconds on `$GOROOT/src`. 345 346 * parse source code and build AST once 347 348 Parsing one source file takes 200 us on average. Parsing of all files in `$GOROOT/src` takes 2 seconds. 349 Currently we parse each file more than once because it's not the bottleneck. But we already save a lot of 350 extra parsing. We're planning to parse each file only once. 351 352 * walk files and directories once 353 354 It takes 300-1000 ms for `$GOROOT/src`. 355 2. Smart linters scheduling 356 357 We schedule linters by a special algorithm which takes estimated execution time into account. It allows 358 to save 10-30% of time when one of heavy linters (megacheck etc) is enabled. 359 360 3. Don't fork to run shell commands 361 362 All linters are vendored in the `/vendor` folder: their version is fixed, they are builtin 363 and you don't need to install them separately. 364 365 ## Supported Linters 366 367 To see a list of supported linters and which linters are enabled/disabled: 368 369 ```bash 370 golangci-lint help linters 371 ``` 372 373 ### Enabled By Default Linters 374 375 {{.EnabledByDefaultLinters}} 376 377 ### Disabled By Default Linters (`-E/--enable`) 378 379 {{.DisabledByDefaultLinters}} 380 381 ## Configuration 382 383 The config file has lower priority than command-line options. If the same bool/string/int option is provided on the command-line 384 and in the config file, the option from command-line will be used. 385 Slice options (e.g. list of enabled/disabled linters) are combined from the command-line and config file. 386 387 To see a list of enabled by your configuration linters: 388 389 ```bash 390 golangci-lint linters 391 ``` 392 393 ### Command-Line Options 394 395 ```bash 396 golangci-lint run -h 397 {{.RunHelpText}} 398 ``` 399 400 ### Config File 401 402 GolangCI-Lint looks for config files in the following paths from the current working directory: 403 404 * `.golangci.yml` 405 * `.golangci.toml` 406 * `.golangci.json` 407 408 GolangCI-Lint also searches for config files in all directories from the directory of the first analyzed path up to the root. 409 To see which config file is being used and where it was sourced from run golangci-lint with `-v` option. 410 411 Config options inside the file are identical to command-line options. 412 You can configure specific linters' options only within the config file (not the command-line). 413 414 There is a [`.golangci.example.yml`](https://github.com/golangci/golangci-lint/blob/master/.golangci.example.yml) example 415 config file with all supported options, their description and default value: 416 417 ```yaml 418 {{.GolangciYamlExample}} 419 ``` 420 421 It's a [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml) config file of this repo: we enable more linters 422 than the default and have more strict settings: 423 424 ```yaml 425 {{.GolangciYaml}} 426 ``` 427 428 ## False Positives 429 430 False positives are inevitable, but we did our best to reduce their count. For example, we have a default enabled set of [exclude patterns](#command-line-options). If a false positive occurred you have the following choices: 431 432 1. Exclude issue by text using command-line option `-e` or config option `issues.exclude`. It's helpful when you decided to ignore all issues of this type. Also, you can use `issues.exclude-rules` config option for per-path or per-linter configuration. 433 2. Exclude this one issue by using special comment `//nolint` (see [the section](#nolint) below). 434 3. Exclude issues in path by `run.skip-dirs`, `run.skip-files` or `issues.exclude-rules` config options. 435 436 Please create [GitHub Issues here](https://github.com/golangci/golangci-lint/issues/new) if you find any false positives. We will add it to the default exclude list if it's common or we will fix underlying linter. 437 438 ### Nolint 439 440 To exclude issues from all linters use `//nolint`. For example, if it's used inline (not from the beginning of the line) it excludes issues only for this line. 441 442 ```go 443 var bad_name int //nolint 444 ``` 445 446 To exclude issues from specific linters only: 447 448 ```go 449 var bad_name int //nolint:golint,unused 450 ``` 451 452 To exclude issues for the block of code use this directive on the beginning of a line: 453 454 ```go 455 //nolint 456 func allIssuesInThisFunctionAreExcluded() *string { 457 // ... 458 } 459 460 //nolint:govet 461 var ( 462 a int 463 b int 464 ) 465 ``` 466 467 Also, you can exclude all issues in a file by: 468 469 ```go 470 //nolint:unparam 471 package pkg 472 ``` 473 474 You can see more examples of using `//nolint` in [our tests](https://github.com/golangci/golangci-lint/tree/master/pkg/result/processors/testdata) for it. 475 476 Use `//nolint` instead of `// nolint` because machine-readable comments should have no space by Go convention. 477 478 ## FAQ 479 480 **How do you add a custom linter?** 481 482 You can integrate it yourself, see this [wiki page](https://github.com/golangci/golangci-lint/wiki/How-to-add-a-custom-linter) with documentation. Or you can create a [GitHub Issue](https://github.com/golangci/golangci-lint/issues/new) and we will integrate when time permits. 483 484 **It's cool to use `golangci-lint` when starting a project, but what about existing projects with large codebase? It will take days to fix all found issues** 485 486 We are sure that every project can easily integrate `golangci-lint`, even the large one. The idea is to not fix all existing issues. Fix only newly added issue: issues in new code. To do this setup CI (or better use [GolangCI](https://golangci.com)) to run `golangci-lint` with option `--new-from-rev=HEAD~1`. Also, take a look at option `--new`, but consider that CI scripts that generate unstaged files will make `--new` only point out issues in those files and not in the last commit. In that regard `--new-from-rev=HEAD~1` is safer. 487 By doing this you won't create new issues in your code and can choose fix existing issues (or not). 488 489 **How to use `golangci-lint` in CI (Continuous Integration)?** 490 491 You have 2 choices: 492 493 1. Use [GolangCI](https://golangci.com): this service is highly integrated with GitHub (issues are commented in the pull request) and uses a `golangci-lint` tool. For configuration use `.golangci.yml` (or toml/json). 494 2. Use custom CI: just run `golangci-lint` in CI and check the exit code. If it's non-zero - fail the build. The main disadvantage is that you can't see issues in pull request code and would need to view the build log, then open the referenced source file to see the context. 495 496 We don't recommend vendoring `golangci-lint` in your repo: you will get troubles updating `golangci-lint`. Please, use recommended way to install with the shell script: it's very fast. 497 498 **Do I need to run `go install`?** 499 500 No, you don't need to do it anymore. 501 502 **Which go versions are supported** 503 Short answer: go 1.11 and newer are oficially supported. 504 505 Long answer: 506 1. go < 1.9 isn't supported 507 2. go 1.9 is supported by golangci-lint <= v1.10.2 508 3. go 1.10 is officially supported by golangci-lint <= 1.15.0. 509 4. go1.11 and go1.12 are officially supported by the latest version of golangci-lint. 510 511 **`golangci-lint` doesn't work** 512 513 1. Update it: `go get -u github.com/golangci/golangci-lint/cmd/golangci-lint` 514 2. Run it with `-v` option and check the output. 515 3. If it doesn't help create a [GitHub issue](https://github.com/golangci/golangci-lint/issues/new) with the output from the error and #2 above. 516 517 **Why running with `--fast` is slow on the first run?** 518 Because the first run caches type information. All subsequent runs will be fast. 519 Usually this options is used during development on local machine and compilation was already performed. 520 521 ## Thanks 522 523 Thanks to all [contributors](https://github.com/golangci/golangci-lint/graphs/contributors)! 524 Thanks to [alecthomas/gometalinter](https://github.com/alecthomas/gometalinter) for inspiration and amazing work. 525 Thanks to [bradleyfalzon/revgrep](https://github.com/bradleyfalzon/revgrep) for cool diff tool. 526 527 Thanks to developers and authors of used linters: 528 {{.ThanksList}} 529 530 ## Changelog 531 532 Follow the news and releases on our [twitter](https://twitter.com/golangci) and our [blog](https://medium.com/golangci). 533 There is the most valuable changes log: 534 535 ### June 2019 536 537 1. treat Go source files as a plain text by `misspell`: it allows detecting issues in strings, variable names, etc. 538 2. implement richer and more stable auto-fix of `misspell` issues. 539 540 ### May 2019 541 542 1. Add [bodyclose](https://github.com/timakin/bodyclose) linter. 543 2. Support junit-xml output. 544 545 ### April 2019 546 547 1. Update go-critic, new checkers were added: badCall, dupImports, evalOrder, newDeref 548 2. Fix staticcheck panic on packages that do not compile 549 3. Make install script work on Windows 550 4. Fix compatibility with the latest x/tools version and update golang.org/x/tools 551 5. Correct import path of module sourcegraph/go-diff 552 6. Fix `max-issues-per-linter` name 553 7. Fix linting of preprocessed files (e.g. `*.qtpl.go`, goyacc) 554 8. Enable auto-fixing when running via pre-commit 555 556 ### March 2019 557 558 1. Support the newest `go vet` (with `go/analysis`) 559 2. Support configuration of `go vet`: e.g. you can set print functions by `linters-settings.govet.settings.printf.funcs` 560 3. Update megacheck (staticcheck) to 2019.1.1 561 4. Add [information](https://github.com/golangci/golangci-lint#memory-usage-of-golangci-lint) about controlling space-time trade-off into README 562 5. Exclude issues by source code line regexp by `issues.exclude-rules[i].source` 563 6. Build and test on go 1.12 564 7. Support `--color` option 565 8. Update x/tools to fix c++ issues 566 9. Include support for log level 567 10. Sort linters list in help commands 568 569 ### February 2019 570 571 1. Implement auto-fixing for `gofmt`, `goimports` and `misspell` 572 2. Update `unparam`, `goimports`, `gosec` and `go-critic` 573 3. Support `issues.exclude-rules` config option 574 4. Add more `identifier` marking patterns 575 5. Add code-climate output format 576 6. Fix diff parsing on windows 577 7. Add version information to built artifact for go1.12 578 8. Dockerfile: copy the binary to `/usr/bin/` instead of `$GOPATH/bin/` 579 9. Support `ignore-words` config option for `misspell` 580 10. Include `staticcheck` check name into a message 581 11. Fix working with symbolic links 582 583 ### January 2019 584 585 1. Update `megacheck` (`staticcheck`), `unparam` and `go-critic` to the latest versions. 586 2. Support the new `stylecheck` linter. 587 3. Support of `enabled-tags` options for `go-critic`. 588 4. Make rich debugging for `go-critic` and meticulously validate `go-critic` checks config. 589 5. Update and use upstream versions of `unparam` and `interfacer` instead of forked ones. 590 6. Improve handling of unknown linter names in `//nolint` directives. 591 7. Speedup `typecheck` on large project with compilation errors. 592 8. Add support for searching for `errcheck` exclude file. 593 9. Fix `go-misc` checksum. 594 10. Don't crash when staticcheck panics 595 596 ### December 2018 597 598 1. Update `goimports`: the new version creates named imports for name/path mismatches. 599 2. Update `go-critic` to the latest version. 600 3. Sync default `go-critic` checks list with the `go-critic`. 601 4. Support `pre-commit.com` hooks. 602 5. Rework and simplify `--skip-dirs` for some edge cases. 603 6. Add `modules-download-mode` option: it's useful in CI. 604 7. Better validate commands. 605 8. Fix working with absolute paths. 606 9. Fix `errcheck.ignore` option. 607 608 ### November 2018 609 610 1. Support new linters: 611 * gocritic 612 * scopelint 613 * gochecknointis 614 * gochecknoglobals 615 2. Update CLA 616 617 ### October 2018 618 619 1. Update goimports formatting 620 2. Use go/packages 621 * A lot of linters became "fast": they are enabled by --fast now and 622 work in 1-2 seconds. Only unparam, interfacer and megacheck 623 are "slow" linters now. 624 625 * Average project is analyzed 20-40% faster than before if all linters are 626 enabled! If we enable all linters except unparam, interfacer and 627 megacheck analysis is 10-20x faster! 628 3. Support goimports.local-prefix option for goimports 629 4. Change license from AGPL to GPL 630 631 ### September 2018 632 633 1. Rename GAS to gosec 634 2. Drop go1.9 support 635 3. Support installation of golangci-lint via go modules 636 4. Update dockerfile to use golang 1.11 637 5. Add support for ignore/exclude flags in errcheck 638 639 ### August 2018 640 641 1. Improve lll parsing for very long lines 642 2. Update Depguard with a Glob support 643 3. Silent output by default 644 4. Disable GAS (gosec) by default 645 5. Build golangci-lint on go1.11 646 647 ### July 2018 648 649 1. Add `golangci-lint linters` command 650 2. Fix work with symlinks 651 652 ### June 2018 653 654 1. Add support of the next linters: 655 * unparam 656 * misspell 657 * prealloc 658 * nakedret 659 * lll 660 * depguard 661 2. Smart generated files detector 662 3. Full `//nolint` support 663 4. Implement `--skip-files` and `--skip-dirs` options 664 5. Checkstyle output format support 665 666 ### May 2018 667 668 1. Support GitHub Releases 669 2. Installation via Homebrew and Docker 670 671 ## Future Plans 672 673 1. Upstream all changes of forked linters. 674 2. Make it easy to write own linter/checker: it should take a minimum code, have perfect documentation, debugging and testing tooling. 675 3. Speed up SSA loading: on-disk cache and existing code profiling-optimizing. 676 4. Analyze (don't only filter) only new code: analyze only changed files and dependencies, make incremental analysis, caches. 677 5. Smart new issues detector: don't print existing issues on changed lines. 678 6. Minimize false-positives by fixing linters and improving testing tooling. 679 7. Automatic issues fixing (code rewrite, refactoring) where it's possible. 680 8. Documentation for every issue type. 681 682 ## Contact Information 683 684 You can contact the [author](https://github.com/jirfag) of GolangCI-Lint 685 by [denis@golangci.com](mailto:denis@golangci.com). Follow the news and releases on our [twitter](https://twitter.com/golangci) and our [blog](https://medium.com/golangci). 686 687 ## License Scan 688 689 [![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Fgolangci%2Fgolangci-lint.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Fgolangci%2Fgolangci-lint?ref=badge_large)