如何让 golint 在 VS Code 上按类型运行而不是在保存时运行?

Ale*_*lex 6 go visual-studio-code

我正在使用 VS Code 和 lukehoban 的 Go 扩展:

https://github.com/Microsoft/vscode-go

当您保存文件时,似乎运行了 golint,有没有办法让我在开始输入时运行 golint?通常在我们输入其他扩展和语言(例如 jslint 和 VS Code 上的 tslint)时会发生 linting。如果可以选择使用 golint 也能做到这一点,那就太好了。

我能做些什么来实现这一目标?

caa*_*os0 5

似乎根本不可能。

关于 golint 唯一可用的配置是:

  // Run Lint tool on save.
  "go.lintOnSave": true,

  // Specifies Lint tool name.
  "go.lintTool": "golint",

  // Flags to pass to Lint tool (e.g. ["-min_confidence=.8"])
  "go.lintFlags": [],
Run Code Online (Sandbox Code Playgroud)

也许你可以通过更改这些选项来解决这个问题:

  // Controls auto save of dirty files. Accepted values:  "off", "afterDelay", "onFocusChange" (editor loses focus), "onWindowChange" (window loses focus). If set to "afterDelay", you can configure the delay in "files.autoSaveDelay".
  "files.autoSave": "off",

  // Controls the delay in ms after which a dirty file is saved automatically. Only applies when "files.autoSave" is set to "afterDelay"
  "files.autoSaveDelay": 1000,
Run Code Online (Sandbox Code Playgroud)

您可以设置files.autoSaveafterDelay或更低files.autoSaveDelay


Dmi*_*hko 5

Go 的这一面让我疯狂......

因此,我找到了一个名为“go.useLanguageServer”的选项(很可能我早些时候就发现了它,但由于某种原因,无论如何找到该选项并不那么容易)。

"go.useLanguageServer": true,
Run Code Online (Sandbox Code Playgroud)

另外,还有这些选项:

"go.languageServerExperimentalFeatures": {
    "diagnostics": true,
    "documentLink": true
},
"go.liveErrors": {
    "enabled": true,
    "delay": 500,
},
Run Code Online (Sandbox Code Playgroud)