Closed SamMcEachern closed 1 week ago
Thanks for sharing your use case @SamMcEachern
Our current plan is to remove the vet support and related code path completely in favor of gopls. Gopls currently does not support a custom analyzer but there is an ongoing discussion about supporting extensible gopls in golang/go#59869.
In the mean time, is it possible to hook your analyzer into a meta linter instead? For example, a simple custom linter can be like
$ cat mylinter.sh
#!/bin/bash
go vet -vettool=$(which shadow) $@ 2>&1
from the settings.json
"go.lintTool": "golint",
"go.alternateTools": {
"golint": "${workspaceRoot}/mylinter.sh"
},
This will cause mylinter.sh to run instead of golint. I think meta-linters like golangci-lint also supports a custom linter (https://golangci-lint.run/contributing/new-linters/#how-to-add-a-private-linter-to-golangci-lint), that is also a possibility.
thanks for the reply @hyangah
Thats a really cool idea! I gave it a go and it seems to run my lint tool. But it seems vscode doesnt visualize the diagnostics because it think an error occurred:
[error] Error while running tool: /<my-directory>/vet.sh
It still prints the diagnostics in the output tab of vscode though. The linting tool im using outputs to stderr, and im guessing vscode-go expects the diagnostics to come to stdout?
Ill try using golangci-lint and see if I get any progress there
@SamMcEachern Thanks for staying flexible. Yes, the extension expects the linter to output to stdout (so I had to redirect stderr to stdout in my example script in https://github.com/golang/vscode-go/issues/3499#issuecomment-2310388511).
@hyangah oh gotcha! It all works if I do the same in my shell script! this works really well, thanks so much!
Is your feature request related to a problem? Please describe. Hello! We want to add custom go vet tools to our vscode settings, allowing us to visualize warnings regarding the framework we are using.
The issue is that While the go language server is active, vscode-go disables the usage of go vet https://github.com/golang/vscode-go/blob/a83a369bfc8da1b866cab98ddd6bb67a3e8e502c/extension/src/goCheck.ts#L132
Describe the solution you'd like Can we enable go vet while the language server is active?
Describe alternatives you've considered We have also tried using the any-lint package. But this is pretty limited and doesnt give a nice visualisation of the warnings like using vscode-go does