英文:
How can I configure the 'staticcheck' linter in Visual Studio Code?
问题
我安装了staticcheck,但它在我的Visual Studio Code中没有显示任何问题。
我已经配置了我的linter来使用staticcheck,并且我在互联网上到处查找。但它仍然不起作用。
这是我的settings.json文件的一部分:
{
  "go.formatTool": "goimports",
  "go.useLanguageServer": true,
  "go.lintTool": "staticcheck",
  "go.lintFlags": [],
  "go.testFlags": ["-v"],
  "go.toolsManagement.autoUpdate": true,
  "editor.codeActionsOnSave": { "source.fixAll.eslint": true }
}
我已经尝试在go.lintFlags中添加"-check=all"。我重新加载了Visual Studio Code,但它仍然不起作用。
当我查看官方网站时,他们提到了staticcheck.conf,但我不明白,因为我的系统上有多个名为staticcheck.conf的文件。
英文:
I installed staticcheck, but it doesn't tell me any problems in my Visual Studio Code.
I configured my linter to use staticcheck and I looked everywhere on the Internet. It still doesn't work.
Here is a part of my settings.json file:
{
  "go.formatTool": "goimports",
  "go.useLanguageServer": true,
  "go.lintTool": "staticcheck",
  "go.lintFlags": [],
  "go.testFlags": ["-v"],
  "go.toolsManagement.autoUpdate": true,
  "editor.codeActionsOnSave": { "source.fixAll.eslint": true }
}
I already tried to add "-check=all" on the go.lintFlags. I reloaded my Visual Studio Code, but it still doesn't work.
When I checked the official website they talk about staticcheck.conf, but I don't get it since there are multiple files named staticcheck.conf on my system.
答案1
得分: 4
你不需要使用"go.lintTool": "staticcheck",因为staticcheck是vscode-go中的默认代码检查工具。
如果你启用了语言服务器,你需要显式地打开staticcheck,可以参考这里的说明,在gopls中设置"ui.diagnostic.staticcheck": true。
作为替代方案,你可以设置golangci-lint作为你的代码检查工具,并在其中打开staticcheck。
英文:
You don't need "go.lintTool": "staticcheck", because, this is (staticcheck) default linting tool in vscode-go.
If you have language serve enabled, you need to turn staticcheck explicitly with
"gopls": { "ui.diagnostic.staticcheck": true }.
As alternative, you can set up golangci-lint as your linter and turn staticcheck in it.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论