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

Commit

Permalink
small improvements for golangci-lint support
Browse files Browse the repository at this point in the history
  • Loading branch information
golangcidev committed May 26, 2018
1 parent 797331c commit 742f1c5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
7 changes: 6 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`)
- Lint-on-save (using `golint` or `gometalinter` or `megacheck` or `golangci-lint`)
- 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 @@ -92,6 +92,11 @@ may have significantly better performance than `gometalinter`, while only suppor

Another alternative is [golangci-lint](https://github.com/golangci/golangci-lint) which shares some of the performance
characteristics of megacheck, but supports a broader range of tools.
You can configure golangci-lint with `go.lintFlags`, for example to show issues only in new code and to enable all linters:

```javascript
"go.lintFlags": ["--enable-all", "--new"],
```

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
5 changes: 5 additions & 0 deletions src/goInstallTools.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const importantTools = [
'golint',
'gometalinter',
'megacheck',
'golangci-lint',
'dlv'
];

Expand Down Expand Up @@ -113,6 +114,10 @@ function getTools(goVersion: SemVersion): string[] {
tools.push('megacheck');
}

if (goConfig['lintTool'] === 'golangci-lint') {
tools.push('golangci-lint');
}

if (goConfig['useLanguageServer'] && process.platform !== 'win32') {
tools.push('go-langserver');
}
Expand Down
4 changes: 4 additions & 0 deletions src/goLint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@ export function goLint(fileUri: vscode.Uri, goConfig: vscode.WorkspaceConfigurat
if (args.indexOf('run') === -1) {
args.unshift('run');
}
if (args.indexOf('--print-issued-lines') === -1) {
// print only file:number:column
args.push('--print-issued-lines=false');
}
}

if (lintWorkspace && currentWorkspace) {
Expand Down

0 comments on commit 742f1c5

Please sign in to comment.