Skip to content

Commit 69a02c8

Browse files
authored
Update README
1 parent 55e73ca commit 69a02c8

File tree

1 file changed

+35
-7
lines changed

1 file changed

+35
-7
lines changed

README.md

+35-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,46 @@
11
This is an example linter that can be compiled into a plugin for `golangci-lint`.
22

3-
To use this, download the code (I haven't found a way to enable `go get` functionality for plugins yet, if you know it let me know!).
3+
To use this:
44

5-
From the root project directory, run `go build -buildmode=plugin -o plugin/example.go`. Then copy the generated `example.so` file into your project or to some other known location of your choosing. Alternately, you can use the `-o /path/to/location/example.so` output flag to have it put it there for you.
5+
### Create the Plugin From This Linter
66

7-
Next, download the `i473` branch of https://github.com/dbraley/golangci-lint/tree/i473 (will be easier once the PR created and merged, sorry).
7+
1. Download the code \*
8+
2. From the root project directory, run `go build -buildmode=plugin -o plugin/example.go`.
9+
3. Copy the generated `example.so` file into your project or to some other known location of your choosing. \**
810

9-
From that projects root directy, run `make vendor_free_build`, which will create a local version of golangci-lint. Feel free to copy it to locations as well, however you want to access it.
1011

11-
In the project you want to lint, copy the golangci.yml file if you do not have one. Adjust the yaml to appropriate `linters-settings:custom` entries, and if `disable-all` is true add the linter name to `linters:enabled` (or manually enable them):
12+
### Create a Copy of `golangci-lint` that Can Run with Plugins
13+
(After the PR this will be either the production code or simpler to get hopefully)
1214

15+
1. Download the `i473` branch of https://github.com/dbraley/golangci-lint/tree/i473
16+
2. From that projects root directy, run `make vendor_free_build`
17+
3. Copy the `golangci-lint` executable that was created to your path, project, or other location
18+
19+
### Configure Your Project for Linting
20+
21+
1. If the project you want to lint does not have one already, copy the https://github.com/dbraley/golangci-lint/blob/i473/.golangci.yml to the root directory.
22+
2. Adjust the yaml to appropriate `linters-settings:custom` entries as so:
1323
```
1424
linters-settings:
1525
custom:
16-
example:
17-
path: /example.so #probably need to adjust this
26+
example: # If this doesn't match the linters name definition, it will warn you but still run
27+
path: /example.so # Adjust this the location of the plugin
28+
enabled: true # This determines if the linter is run by default
29+
original-url: github.com/dbraley/example-linter # This is just documentation for custom linters
30+
slow: false # Set this to true to observe `--fast` option
31+
```
32+
3. If your `.golangci.yml` file has `linters:disable-all` set to true, you'll also need to add your linter to the `linters:enable` seciont:
1833
```
34+
linters:
35+
enable:
36+
# ...
37+
- varcheck
38+
- whitespace
39+
# Custom linters
40+
- example
41+
```
42+
4. Alternately, you can leave it disabled and turn it on via command line only: `golangci-lint run -Eexample`
43+
44+
45+
\* Sorry, I haven't found a way to enable `go get` functionality for plugins yet. If you know how, let me know!
46+
\** Alternately, you can use the `-o /path/to/location/example.so` output flag to have it put it there for you.

0 commit comments

Comments
 (0)