-
Notifications
You must be signed in to change notification settings - Fork 798
goLint: linting with golangci-lint v2 fails #3732
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I'm willing to work on this issue! Declaring "golangci-lint v2" as a linter choice might be a good idea... |
I think this is the best option. If it's feasible (I haven't looked at goLint.ts) I think it would be a good idea to detect "Error: unknown flag" and pop up a notification, "It appears that you are using golangci-lint v2, in which case you should set |
That looks awesome to me! Thx |
Change https://go.dev/cl/660415 mentions this issue: |
Thank you for raising this issue and working on the CL.
This make sense. There are some complexity here beyond the CL crafted. We need to figure out a way to make sure the different version of the binary can co-exist in the GOBIN. Both v1 and v2 golangci-lint have the exact same name, so calling There is a FR raised in go asking for @matloob suggested we can do the following to work this around:
In the meantime, we need to consider another configuration As said above, there might be some extra work vscode-go need to do to manage different versions of the same binary like |
Is this being worked on? |
Yup, of course! Sorry for making you wait. |
Submitted an implementation. Agree with all of @h9jiang points. Will likely need a more centralized way of supporting multiple versions of the same binary. |
@arhea Thank you, |
Great, will do! |
If anyone is looking for a workaround until this feature is released this is what I did
cp ~/go/bin/golangci-lint ~/go/bin/golangci-lint-v2
"go.lintFlags": [
"run",
"--issues-exit-code=0",
"--output.text.colors=true",
"--output.text.path=stdout",
"--output.text.print-issued-lines=false",
"--show-stats=false"
],
"go.lintTool": "golangci-lint-v2", VSCode's settings validator will complain about the |
@sherif-fanous Thank you so much for the workaround provided. One thing to note, But the idea of keep the v2 binary as name We hope we can make this migration merged in v0.48.0 and we can release a prerelease version v0.47.2 to have this migration release early (if people are willing to switch to a prerelease version). |
@marcusthelin Not clear from the screenshot what you mean by the path is duplicated. I see 2 similar violations but on different lines (157 vs 159) |
Sorry. It should not be |
@marcusthelin had the same issue, looks like it was due to Slightly confused because this issue persisted after I reverted to |
FYI, Remember that:
You should migrate your configuration: https://golangci-lint.run/product/migration-guide/ |
@ldez until this is fixed, maybe its worth considering changing the integration docs (as this is a potential blocker for migration) |
I will add the link to this issue inside the documentation. |
I might be being to simplistic but can you not parse the output of
|
This wouldn't work if you have many projects that use both v1 and v2. |
@lummie But don't worry! I implemented the version detection logic differently in the current version of the Pull Request! The detail: (https://go.dev/cl/660415)
If you have any further questions, please don't hesitate to mention me! |
Just tried the fix. I had to add below settings to .golangci.yml in order to generate the path of findings correctly, but other than it it works great! Thanks!
|
If you have to set the relative path mode to @logica0419 I need a confirmation of the problem, and be sure that it is not a side effect of something inside the extension. |
Without the
Here is my
|
I will take a look, thank you. |
For users seeking a temporary workaround: |
I tried the current master branch, and I confirm the problem.
Edit: it doesn't require This option will only impact the output paths, but not the paths inside the configuration. Note,
@logica0419 The extension will have to set up this option. |
@holyspectral @ldez |
It's related to the update to v2:
The current extension implementation will only work:
To illustrate the problem with exclusions:
rules:
- linters:
- lll
path: api/* And if you edit a file inside But we can switch to another issue, no problem. |
The v0.47.2 is now released with fix for this issue. See https://github.com/golang/vscode-go/releases/tag/v0.47.2 This is a prerelease version of vscode-go extension. You will need to manually switch to pre-release version of vscode-go. ![]() |
This commit adds a note to the docs about how to integrate golangci-lint v2 with VS Code since the Go extension's stable version does not support it yet. For more information on this, you can refer to the linked [vscode-go#3732](golang/vscode-go#3732 (comment)) issue comment. Signed-off-by: lvlcn-t <[email protected]>
This commit adds a note to the docs about how to integrate golangci-lint v2 with VS Code since the Go extension's stable version does not support it yet. For more information on this, you can refer to the linked [vscode-go#3732](golang/vscode-go#3732 (comment)) issue comment. Signed-off-by: lvlcn-t <[email protected]>
Even after upgrading to the pre-release version of the extension, I'm getting the same exact error message. I installed golangci-lint v2 via chocolatey. |
What version of Go, VS Code & VS Code Go extension are you using?
Version Information
go version
to get version of Go from the VS Code integrated terminal.gopls -v version
to get version of Gopls from the VS Code integrated terminal.code -v
orcode-insiders -v
to get version of VS Code or VS Code Insiders.Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
Describe the bug
After updating golangci-lint to v2, lining using golanci-lint always fails with the logs below.
This error occurs because
--print-issued-lines
and--out-format
flags were deleted in v2.These flags seem to have the same output in v2.
Thus, we need to switch flags depending on the version of golangci-lint.
Steps to reproduce the behavior:
Screenshots or recordings
If applicable, add screenshots or recordings to help explain your problem.
The text was updated successfully, but these errors were encountered: