Skip to content

Commit ca6effb

Browse files
authored
dev: discourage bad practices (#803)
1 parent 7004896 commit ca6effb

File tree

9 files changed

+179
-110
lines changed

9 files changed

+179
-110
lines changed

.github/ISSUE_TEMPLATE.md

+40-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,43 @@
11
Thank you for creating the issue!
22

3+
- [ ] Yes, I'm using a binary release within 2 latest major releases. Only such installations are supported.
4+
- [ ] Yes, I've searched similar issues on GitHub and didn't find any.
5+
- [ ] Yes, I've included all information below (version, config, etc).
6+
37
Please include the following information:
4-
1. Version of golangci-lint: `golangci-lint --version` (or git commit if you don't use binary distribution)
5-
2. Config file: `cat .golangci.yml`
6-
3. Go environment: `go version && go env`
7-
4. Verbose output of running: `golangci-lint run -v`
8+
9+
<details><summary>Version of golangci-lint</summary>
10+
11+
```bash
12+
$ golangci-lint --version
13+
# paste output here
14+
```
15+
16+
</details>
17+
18+
<details><summary>Config file</summary>
19+
20+
```bash
21+
$ cat .golangci.yml
22+
# paste output here
23+
```
24+
25+
</details>
26+
27+
<details><summary>Go environment</summary>
28+
29+
```bash
30+
$ go version && go env
31+
# paste output here
32+
```
33+
34+
</details>
35+
36+
<details><summary>Verbose output of running</summary>
37+
38+
```bash
39+
$ golangci-lint run -v
40+
# paste output here
41+
```
42+
43+
</details>

.golangci.example.yml

-1
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ linters:
225225
enable:
226226
- megacheck
227227
- govet
228-
enable-all: false
229228
disable:
230229
- maligned
231230
- prealloc

.golangci.yml

+1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ linters-settings:
4848
statements: 50
4949

5050
linters:
51+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
5152
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
5253
disable-all: true
5354
enable:

README.md

+58-52
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,42 @@ Sponsored by [GolangCI.com](https://golangci.com): SaaS service for running lint
1414

1515
<a href="https://golangci.com/"><img src="docs/go.png" width="250px"></a>
1616

17-
* [Demo](#demo)
18-
* [Install](#install)
19-
* [Trusted By](#trusted-by)
20-
* [Quick Start](#quick-start)
21-
* [Editor Integration](#editor-integration)
22-
* [Shell Completion](#shell-completion)
23-
* [Comparison](#comparison)
24-
* [Performance](#performance)
25-
* [Internals](#internals)
26-
* [Supported Linters](#supported-linters)
27-
* [Configuration](#configuration)
28-
* [False Positives](#false-positives)
29-
* [FAQ](#faq)
30-
* [Thanks](#thanks)
31-
* [Changelog](#changelog)
32-
* [Debug](#debug)
33-
* [Future Plans](#future-plans)
34-
* [Contact Information](#contact-information)
17+
- [GolangCI-Lint](#golangci-lint)
18+
- [Demo](#demo)
19+
- [Install](#install)
20+
- [Binary Release](#binary-release)
21+
- [MacOS](#macos)
22+
- [By Docker](#by-docker)
23+
- [go get](#go-get)
24+
- [Trusted By](#trusted-by)
25+
- [Quick Start](#quick-start)
26+
- [Editor Integration](#editor-integration)
27+
- [Shell Completion](#shell-completion)
28+
- [Mac OS X](#mac-os-x)
29+
- [Linux](#linux)
30+
- [Comparison](#comparison)
31+
- [`golangci-lint` vs `gometalinter`](#golangci-lint-vs-gometalinter)
32+
- [`golangci-lint` vs Running Linters Manually](#golangci-lint-vs-running-linters-manually)
33+
- [Performance](#performance)
34+
- [Comparison with gometalinter](#comparison-with-gometalinter)
35+
- [Why golangci-lint is faster](#why-golangci-lint-is-faster)
36+
- [Memory Usage of Golangci-lint](#memory-usage-of-golangci-lint)
37+
- [Internals](#internals)
38+
- [Supported Linters](#supported-linters)
39+
- [Enabled By Default Linters](#enabled-by-default-linters)
40+
- [Disabled By Default Linters (`-E/--enable`)](#disabled-by-default-linters--e--enable)
41+
- [Configuration](#configuration)
42+
- [Command-Line Options](#command-line-options)
43+
- [Config File](#config-file)
44+
- [False Positives](#false-positives)
45+
- [Nolint](#nolint)
46+
- [FAQ](#faq)
47+
- [Thanks](#thanks)
48+
- [Changelog](#changelog)
49+
- [Debug](#debug)
50+
- [Future Plans](#future-plans)
51+
- [Contact Information](#contact-information)
52+
- [License Scan](#license-scan)
3553

3654
## Demo
3755

@@ -44,28 +62,28 @@ Short 1.5 min video demo of analyzing [beego](https://github.com/astaxie/beego).
4462

4563
## Install
4664

47-
### CI Installation
65+
### Binary Release
4866

4967
Most installations are done for CI (travis, circleci etc). It's important to have reproducible CI:
5068
don't start to fail all builds at the same time. With golangci-lint this can happen if you
51-
use `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded.
69+
use deprecated option `--enable-all` and a new linter is added or even without `--enable-all`: when one upstream linter is upgraded.
5270

5371
It's highly recommended to install a fixed version of golangci-lint.
5472
Releases are available on the [releases page](https://github.com/golangci/golangci-lint/releases).
5573

56-
Latest version: ![GitHub release](https://img.shields.io/github/release/golangci/golangci-lint.svg)
74+
Latest version: [v1.20.0](https://github.com/golangci/golangci-lint/releases/tag/v1.20.0)
5775

58-
Here is the recommended way to install golangci-lint (replace `vX.Y.Z` with the latest version):
76+
Here is the recommended way to install golangci-lint:
5977

6078
```bash
6179
# binary will be $(go env GOPATH)/bin/golangci-lint
62-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin vX.Y.Z
80+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b $(go env GOPATH)/bin v1.20.0
6381

6482
# or install it into ./bin/
65-
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z
83+
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.20.0
6684

6785
# In alpine linux (as it does not come with curl by default)
68-
wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s vX.Y.Z
86+
wget -O - -q https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s v1.20.0
6987

7088
golangci-lint --version
7189
```
@@ -74,41 +92,30 @@ Periodically update version of golangci-lint: the project is under active develo
7492
and is constantly being improved. But please always check for newly found issues and
7593
update if needed.
7694

77-
### Local Installation
95+
### MacOS
7896

79-
Local installation is not recommended for your CI pipeline. Only install the linter this way in a local development environment.
80-
81-
#### Windows, MacOS and Linux
82-
83-
```bash
84-
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
85-
```
86-
87-
With `go1.12` or later you can get a particular version
88-
89-
```bash
90-
GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/[email protected]
91-
```
92-
93-
#### MacOS
94-
95-
You can also install it on MacOS using [brew](https://brew.sh/):
97+
You can also install a binary release on MacOS using [brew](https://brew.sh/):
9698

9799
```bash
98100
brew install golangci/tap/golangci-lint
99101
brew upgrade golangci/tap/golangci-lint
100102
```
101103

102-
#### `--version`
103-
104-
If you need your local `golangci-lint --version` to show proper version additionally run:
104+
### By Docker
105105

106106
```bash
107-
cd $(go env GOPATH)/src/github.com/golangci/golangci-lint/cmd/golangci-lint
108-
go install -ldflags "-X 'main.version=$(git describe --tags)' -X 'main.commit=$(git rev-parse --short HEAD)' -X 'main.date=$(date)'"
107+
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:v1.20.0 golangci-lint run -v
109108
```
110109

111-
On Windows, you can run the above commands with Git Bash, which comes with [Git for Windows](https://git-scm.com/download/win).
110+
### go get
111+
112+
Please, do not install `golangci-lint` by `go get`:
113+
114+
1. [`go.mod`](https://github.com/golangci/golangci-lint/blob/master/go.mod) replacement directive doesn't apply. It means you will be using patched version of `golangci-lint`.
115+
2. it's much slower than binary installation
116+
3. it's stability depends on your Go version (e.g. on [this compiler Go <= 1.12 bug](https://github.com/golang/go/issues/29612)).
117+
4. it's not guaranteed to work: e.g. we've encountered a lot of issues with Go modules hashes.
118+
5. it allows installation from `master` branch which can't be considered stable.
112119

113120
## Trusted By
114121

@@ -515,7 +522,6 @@ Flags:
515522
--skip-files strings Regexps of files to skip
516523
-E, --enable strings Enable specific linter
517524
-D, --disable strings Disable specific linter
518-
--enable-all Enable all linters
519525
--disable-all Disable all linters
520526
-p, --presets strings Enable presets (bugs|complexity|format|performance|style|unused) of linters. Run 'golangci-lint linters' to see them. This option implies option --disable-all
521527
--fast Run only fast linters from enabled linters set (first run won't be fast)
@@ -818,7 +824,6 @@ linters:
818824
enable:
819825
- megacheck
820826
- govet
821-
enable-all: false
822827
disable:
823828
- maligned
824829
- prealloc
@@ -945,6 +950,7 @@ linters-settings:
945950
statements: 50
946951
947952
linters:
953+
# please, do not use `enable-all`: it's deprecated and will be removed soon.
948954
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
949955
disable-all: true
950956
enable:
@@ -1097,7 +1103,7 @@ Long answer:
10971103
10981104
**`golangci-lint` doesn't work**
10991105
1100-
1. Update it: `go get -u github.com/golangci/golangci-lint/cmd/golangci-lint`
1106+
1. Please, ensure you are using the latest binary release.
11011107
2. Run it with `-v` option and check the output.
11021108
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.
11031109

0 commit comments

Comments
 (0)