我正在尝试将 golangci-lint 与 vscode 集成。这是我在 vscode 中的设置文件
"go.lintTool": "golangci-lint",
"go.lintFlags": ["--fast"],
"go.liveErrors": {
"enabled": true,
"delay": 500
},
"go.lintOnSave": "workspace",
"editor.codeActionsOnSave": {
"source.organizeImports": true
},
"go.useLanguageServer": true,
"go.languageServerExperimentalFeatures": {
"diagnostics": true
}
但是 vscode 上没有显示任何错误/警告。最初它出现,但突然消失了。另外,我知道 linting 工具又使用了许多其他 linters,如 errcheck 、 ineffassign 等,我是否必须单独安装它们?
最佳答案
我遇到了类似的问题,我通过从配置中删除 --fast
标志并通过 VS Code 插件重新运行 linter,然后将其添加回来来解决它。
我怀疑它与 --fast
标志使用的缓存有关:
https://golangci-lint.run/usage/faq/#why-running-with---fast-is-slow-on-the-first-run
关于golangci-lint 在 vscode 上未显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74454813/