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: README.md
+28-19
Original file line number
Diff line number
Diff line change
@@ -28,48 +28,57 @@ If you're looking for instructions on how to configure your own custom linter, t
28
28
29
29
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.
30
30
2. Adjust the YAML to appropriate `linters-settings.custom` entries as so:
31
-
```yml
31
+
```yaml
32
32
linters-settings:
33
-
custom:
34
-
example:
35
-
path: /example.so
36
-
description: The description of the linter
37
-
original-url: github.com/golangci/example-linter
33
+
custom:
34
+
example:
35
+
path: /example.so
36
+
description: The description of the linter
37
+
original-url: github.com/golangci/example-linter
38
+
settings: # Settings are optional.
39
+
one: Foo
40
+
two:
41
+
- name: Bar
42
+
three:
43
+
name: Bar
38
44
```
39
45
40
46
That is all the configuration that is required to run a custom linter in your project.
41
47
42
48
Custom linters are enabled by default, but abide by the same rules as other linters.
43
49
44
50
If the disable all option is specified either on command line or in `.golang.yml` files `linters.disable-all: true`, custom linters will be disabled;
45
-
they can be re-enabled by adding them to the `linters:enable` list,
51
+
they can be re-enabled by adding them to the `linters.enable` list,
46
52
or providing the enabled option on the command line, `golangci-lint run -Eexample`.
47
53
48
-
### To Create Your Own Custom Linter
54
+
The configuration inside the `settings` field of linter have some limitations (there are NOT related to the plugin system itself):
55
+
we use Viper to handle the configuration but Viper put all the keys in lowercase, and `.` cannot be used inside a key.
49
56
50
-
Your linter must implement one or more `golang.org/x/tools/go/analysis.Analyzer` structs.
57
+
### To Create Your Own Plugin
58
+
59
+
Your linter must provide one or more `golang.org/x/tools/go/analysis.Analyzer` structs.
51
60
52
61
Your project should also use `go.mod`.
53
62
54
63
All versions of libraries that overlap `golangci-lint` (including replaced libraries) MUST be set to the same version as `golangci-lint`.
55
64
You can see the versions by running `go version -m golangci-lint`.
56
65
57
-
You'll also need to create a go file like `plugin/example.go`.
58
-
59
-
This MUST be in the package `main`, and define a variable of name `AnalyzerPlugin`.
60
-
The `AnalyzerPlugin` instance MUST implement the following interface:
66
+
You'll also need to create a Go file like `plugin/example.go`.
61
67
68
+
This file MUST be in the package `main`, and MUST define an exposed function called `New` with the following signature:
0 commit comments