golangci-lint在VSCode上没有显示错误。

huangapple go评论109阅读模式
英文:

golangci-lint not showing errors on vscode

问题

我正在尝试将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,比如errcheckineffassign等等,我需要单独安装它们吗?

英文:

I'm trying to integrate golangci-lint with vscode. This is my settings file in 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
  }

However none of the errors/warnings show up on vscode. Initially it was showing up but suddenly disappeared. Also on another note, I know the linting tool in turn use a number of other linters like errcheck ineffassign and so on, do I have to install them separately ?

答案1

得分: 2

我遇到了类似的问题,我通过从配置中删除--fast标志并通过VS Code插件重新运行linter,然后再添加回来来解决它。

我怀疑这与--fast标志使用的缓存有关:
https://golangci-lint.run/usage/faq/#why-running-with---fast-is-slow-on-the-first-run

英文:

I had a similar problem and I solved it by removing --fast flag from the configuration, and rerunning linter via VS Code plugin, then adding it back.

I suspect it had something to do with the cache the --fast flag is using:
https://golangci-lint.run/usage/faq/#why-running-with---fast-is-slow-on-the-first-run

huangapple
  • 本文由 发表于 2022年11月16日 11:32:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/74454813.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定