golangci-lint 在 vscode 上未显示错误

标签 go visual-studio-code golangci-lint

我正在尝试将 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/

相关文章:

go - 为什么我的解决方案不适合 tour of go slices 练习?

intellij-idea - VS 代码键绑定(bind)可用于 IntelliJ Idea 吗?

go - 如何在 GoLand 的虚拟环境中运行 file watcher?

golang linter 总是提示

go - 是否可以进行configure-make-make安装?

用于匹配标签最后一次出现的正则表达式

go - 删除 slice 中的元素导致原始 slice 发生变化?

linux - 命令面板中缺少 "Shell Command: Install"命令 - VS 代码 - ubuntu

visual-studio-code - 使新标签始终是最右边的(在所有标签的末尾)

go - 在 Go 中使用 init() 函数真的很糟糕吗?