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: docs/src/docs/contributing/new-linters.mdx
+31-22Lines changed: 31 additions & 22 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,8 +4,8 @@ title: New linters
4
4
5
5
## How to write a custom linter
6
6
7
-
Use `go/analysis` and take a look at [this tutorial](https://disaev.me/p/writing-useful-go-analysis-linter/): it shows how to write `go/analysis` linter
8
-
from scratch and integrate it into `golangci-lint`.
7
+
Use `go/analysis` and take a look at [this tutorial](https://disaev.me/p/writing-useful-go-analysis-linter/):
8
+
it shows how to write `go/analysis` linter from scratch and integrate it into `golangci-lint`.
9
9
10
10
## How to add a public linter to `golangci-lint`
11
11
@@ -39,52 +39,61 @@ After that:
39
39
40
40
Some people and organizations may choose to have custom-made linters run as a part of `golangci-lint`.
41
41
Typically, these linters can't be open-sourced or too specific.
42
+
42
43
Such linters can be added through Go's plugin library.
43
44
44
45
For a private linter (which acts as a plugin) to work properly,
45
46
the plugin as well as the golangci-lint binary needs to be built for the same environment. `CGO_ENABLED` is another requirement.
47
+
46
48
This means that `golangci-lint` needs to be built for whatever machine you intend to run it on
47
49
(cloning the golangci-lint repository and running a `CGO_ENABLED=1 make build` should do the trick for your machine).
48
50
49
51
### Configure a Plugin
50
52
51
-
If you already have a linter plugin available, you can follow these steps to define it's usage in a projects
52
-
`.golangci.yml` file. An example linter can be found at [here](https://github.com/golangci/example-plugin-linter). If you're looking for
53
-
instructions on how to configure your own custom linter, they can be found further down.
53
+
If you already have a linter plugin available, you can follow these steps to define its usage in a projects `.golangci.yml` file.
54
+
55
+
An example linter can be found at [here](https://github.com/golangci/example-plugin-linter).
56
+
57
+
If you're looking for instructions on how to configure your own custom linter, they can be found further down.
54
58
55
59
1. If the project you want to lint does not have one already, copy the [.golangci.yml](https://github.com/golangci/golangci-lint/blob/master/.golangci.yml) to the root directory.
56
60
2. Adjust the yaml to appropriate `linters-settings:custom` entries as so:
0 commit comments