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

Add support for revive as lintTool #1699

Merged
merged 1 commit into from Jun 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion README.md
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, 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
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
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