简体   繁体   中英

How can I configure the 'staticcheck' linter in Visual Studio Code?

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 Inte.net. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM