From 0576548d9de3f923299ec346aec82bab24e3ed8f Mon Sep 17 00:00:00 2001 From: mgechev Date: Wed, 30 May 2018 18:09:19 -0700 Subject: [PATCH] Add support for revive as lintTool --- README.md | 10 +++++++++- package.json | 3 ++- src/goInstallTools.ts | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 695e74c9c..7a3b23376 100644 --- a/README.md +++ b/README.md @@ -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`) @@ -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. diff --git a/package.json b/package.json index 9546bd308..880316769 100644 --- a/package.json +++ b/package.json @@ -522,7 +522,8 @@ "golint", "gometalinter", "megacheck", - "golangci-lint" + "golangci-lint", + "revive" ] }, "go.lintFlags": { diff --git a/src/goInstallTools.ts b/src/goInstallTools.ts index f6e2d9ace..0e2c4d863 100644 --- a/src/goInstallTools.ts +++ b/src/goInstallTools.ts @@ -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' @@ -61,6 +62,7 @@ const importantTools = [ 'gometalinter', 'megacheck', 'golangci-lint', + 'revive', 'dlv' ]; @@ -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'); }