|
1 | 1 | # SublimeLinter-golangcilint [](https://travis-ci.org/SublimeLinter/SublimeLinter-golangcilint) |
2 | 2 |
|
3 | | -This linter plugin for [SublimeLinter](https://github.com/SublimeLinter/SublimeLinter) provides an interface to [golangci-lint](https://github.com/golangci/golangci-lint). |
| 3 | +This linter plugin for [SublimeLinter][docs] provides an interface to [golangci-lint](https://github.com/golangci/golangci-lint), a linter for Go (golang). |
4 | 4 |
|
5 | | -It will be used with files that have the "Go" syntax. |
| 5 | +## Installation |
6 | 6 |
|
7 | | -**Note:** This project was originally inspired by a [similar package](https://github.com/alecthomas/SublimeLinter-contrib-golang-cilint) that unfortunately doesn’t takes in consideration a bug in golangci-lint that sends some errors to `/dev/stderr` rather than `/dev/stdout` causing the linter to fail or miss some important issues. I have fixed this in this version, and also added better error handling for unrelated files. |
| 7 | +- Install SublimeLinter 3 from [here](https://packagecontrol.io/packages/SublimeLinter) |
| 8 | +- Install SublimeLinter-golangcilint from [here](https://packagecontrol.io/packages/SublimeLinter-contrib-golang-cilint) |
| 9 | +- Install the `golangci-lint` helper from [here](https://github.com/golangci/golangci-lint#install) |
8 | 10 |
|
9 | | -## Installation |
| 11 | +## Configuration |
| 12 | + |
| 13 | +In order for `golangci-lint` to be executed by SublimeLinter, you must ensure that its path is available to SublimeLinter. Before going any further, please read and follow the steps in [Finding a linter executable](http://sublimelinter.readthedocs.org/en/latest/troubleshooting.html#finding-a-linter-executable) through “Validating your PATH” in the documentation. Once you have installed `golangci-lint`, you can proceed to install the SublimeLinter-contrib-golangci-lint plugin if it is not yet installed. |
| 14 | + |
| 15 | +**Note:** The linter creates a temporary directory to allow SublimeLinter to scan changes in the code that are still in the buffer _(aka. not saved yet)_. If the SublimeText sidebar is visible, you will notice _—for a split of a second—_ that a folder named `.golangcilint-*` appears and disappears. Make sure to add this folder to your `.gitignore` file, and also the “folder_exclude_patterns” in SublimeText’s preferences: |
| 16 | + |
| 17 | +``` |
| 18 | +{ |
| 19 | + "folder_exclude_patterns": |
| 20 | + [ |
| 21 | + ".svn", |
| 22 | + ".git", |
| 23 | + ".hg", |
| 24 | + "CVS", |
| 25 | + "cache", |
| 26 | + "uploads", |
| 27 | + ".golangci-*", |
| 28 | + ".golangcilint-*", |
| 29 | + ".gometalinter-*" |
| 30 | + ] |
| 31 | +} |
| 32 | +``` |
10 | 33 |
|
11 | | -SublimeLinter must be installed in order to use this plugin. Then use [Package Control](https://packagecontrol.io/) to install the linter plugin. Please make sure that the path to `golangci-lint` is available to SublimeLinter. To install, follow the instructions provided by [here](https://github.com/golangci/golangci-lint#install). |
| 34 | +## Plugin installation |
12 | 35 |
|
| 36 | +Please use [Package Control](https://packagecontrol.io/) to install the linter plugin. This will ensure that the plugin will be updated when new versions are available. If you want to install from source so you can modify the source code, you probably know what you are doing so we won’t cover that here. |
13 | 37 |
|
14 | | -## Settings |
| 38 | +To install via Package Control, do the following: |
15 | 39 |
|
16 | | -- SublimeLinter settings: http://sublimelinter.com/en/latest/settings.html |
17 | | -- Linter settings: http://sublimelinter.com/en/latest/linter_settings.html |
| 40 | +1. Within Sublime Text, “Tools > Command Palette”, then type `install`. Among the commands you should see `Package Control: Install Package`. If that command is not highlighted, use the keyboard or mouse to select it. There will be a pause of a few seconds while Package Control fetches the list of available plugins. |
| 41 | +1. When the plugin list appears, type `golangci-lint`. Among the entries you should see `SublimeLinter-golangcilint`. If that entry is not highlighted, use the keyboard or mouse to select it. |
0 commit comments