-
Notifications
You must be signed in to change notification settings - Fork 763
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
Linter does not support go workspaces (go.work) #2666
Comments
This isn't something vscode has any effect on. Did you mean to file this in golang/go? Related issue at golangci/golangci-lint#2654. |
It's relate to the way vscode execute the lint command |
As @jamalc pointed out, this is a bug in golangci-lint: it appears to be running Unfortunately this is not something we have any control over. |
I am reopening this issue because vscode-go is involved too. The extension still relies on Options:
|
hello i'm facing the same issue when use golangci-lint with jenkins |
I have found a temporary workaround to get golanglint-ci to work until a proper fix comes around. Find your golangci-lint binary with
Change into that directory
Backup golangci-lint. (don't delete it, or move it anywhere else)
make a new file called
Set the file to be executable
And setup golangci-lint as your linter in vscode as per usual. Note: This is likely to break in weird ways, but it works for my simple projects. It's a stopgap until a better solution comes around. Additionally if you update golangci-lint it will likely override your script. You will then need to delete the backup you made, and redo the process |
Golangci-lint seem to have concluded that their linter is not meant to run directly on a workspace and has provided a number of different commands to iterate over all the modules. Seems like this extension should be updated to use one of them instead? |
Change https://go.dev/cl/567715 mentions this issue: |
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.e2816fe719a4026ffa1ee0189dc89bdfdbafb164
x64
Go: Locate Configured Go Tools
command.Share the Go related settings you have added/edited
Go settings
``` "go.buildOnSave": "off", "go.lintOnSave": "workspace", "go.vetOnSave": "workspace", "go.buildTags": "", "go.buildFlags": [], "go.lintTool": "golangci-lint", "go.lintFlags": [ "--fast" ], "go.vetFlags": [], "go.testOnSave": true, "go.coverOnSave": false, "go.useCodeSnippetsOnFunctionSuggest": true, "editor.formatOnSave": true, "go.formatTool": "goimports", "go.formatFlags": [], "go.goroot": "", "go.gopath": "", "go.inferGopath": false, "go.gocodeAutoBuild": false, "go.testFlags": [ "-v" ], "go.useLanguageServer": true, "go.docsTool": "gogetdoc", "go.liveErrors": { "enabled": true, "delay": 500, }, ```
Describe the bug
The lint feature does not work in a go-workspace (go.work) workspace, this also happens if you run the linter manually:
You have to run the linter separatly for each sub-module.
This is how I solved it in our CI:
go work edit -json | jq -r '.Use[].DiskPath' | xargs --verbose -I{} golangci-lint run {}/...
The "Lint Current Package" still works.
We use the repository as monorepo so we actually need all of the go tools for all of the submodules.
Steps to reproduce the behavior:
golangci-lint
as a linterScreenshots or recordings
The error message from the extension output:
The text was updated successfully, but these errors were encountered: