Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add support for revive as lintTool
Browse files Browse the repository at this point in the history
  • Loading branch information
mgechev committed May 31, 2018
1 parent 896ff76 commit c264736
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
10 changes: 9 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ This extension adds rich language support for the Go language to VS Code, includ
- Workspace symbol search (using `go-symbols`)
- Rename (using `gorename`. Note: For Undo after rename to work in Windows you need to have `diff` tool in your path)
- Build-on-save (using `go build` and `go test`)
- Lint-on-save (using `golint` or `gometalinter` or `megacheck` or `golangci-lint`)
- Lint-on-save (using `golint` or `gometalinter` or `megacheck` or `golangci-lint` or `revive`)
- Format on save as well as format manually (using `goreturns` or `goimports` or `gofmt`)
- Generate unit tests skeleton (using `gotests`)
- Add Imports (using `gopkgs`)
Expand Down Expand Up @@ -98,6 +98,14 @@ You can configure golangci-lint with `go.lintFlags`, for example to show issues
"go.lintFlags": ["--enable-all", "--new"],
```

An alternative of golint is [revive](https://github.com/mgechev/revive). It is extensible, configurable, provides superset of the rules of golint rules, and has significantly better performance.

To configure revive, use:

```javascript
"go.lintFlags": ["--exclude vendor/...", "--config=${workspaceRoot}/config.toml"]
```

Finally, the result of those linters will show right in the code (locations with suggestions will be underlined),
as well as in the output pane.

Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,8 @@
"golint",
"gometalinter",
"megacheck",
"golangci-lint"
"golangci-lint",
"revive"
]
},
"go.lintFlags": {
Expand Down
6 changes: 6 additions & 0 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const allTools: { [key: string]: string } = {
'gometalinter': 'github.com/alecthomas/gometalinter',
'megacheck': 'honnef.co/go/tools/...',
'golangci-lint': 'github.com/golangci/golangci-lint/cmd/golangci-lint',
'revive': 'github.com/mgechev/revive',
'go-langserver': 'github.com/sourcegraph/go-langserver',
'dlv': 'github.com/derekparker/delve/cmd/dlv',
'fillstruct': 'github.com/davidrjenni/reftools/cmd/fillstruct'
Expand All @@ -61,6 +62,7 @@ const importantTools = [
'gometalinter',
'megacheck',
'golangci-lint',
'revive',
'dlv'
];

Expand Down Expand Up @@ -118,6 +120,10 @@ function getTools(goVersion: SemVersion): string[] {
tools.push('golangci-lint');
}

if (goConfig['lintTool'] === 'revive') {
tools.push('revive');
}

if (goConfig['useLanguageServer'] && process.platform !== 'win32') {
tools.push('go-langserver');
}
Expand Down

0 comments on commit c264736

Please sign in to comment.