简体   繁体   English

如何在vscode中的Golang Lint工具中忽略文件或路径

[英]How to ignore file or path in golang lint tool in vscode

I am using Go in vscode, but the lint marks me that I have problems in third party packages. 我在vscode中使用Go,但是棉绒使我意识到我在第三方软件包中遇到了问题。

It is possible to put a rule to ignore the src folder, for example? 例如,可以设置规则以忽略src文件夹吗?

在此处输入图片说明

The problems shown on your screenshot are related to go vet and not to golint 屏幕快照上显示的问题与go vet ,而不与golint

To pass an absolute path to go tool vet or golint do as follows: 要通过绝对路径来go tool vetgolint请执行以下操作:

  1. Go to File > Preferences > Settings or hit Ctrl+, 转到File > Preferences > SettingsCtrl+,
  2. Add the file or directory path to "go.vetFlags" or "go.lintFlags" , ie "go.vetFlags": ["/path/to/file"] 将文件或目录路径添加到"go.vetFlags""go.lintFlags" ,即"go.vetFlags": ["/path/to/file"]

For some reason, on go extension 0.6.78 it adds a . 出于某种原因,在扩展0.6.78中添加了. argument to the go tool vet (you can inspect it on OUTPUT tab in VSCode): go tool vet参数(您可以在VSCode的OUTPUT选项卡上对其进行检查):

Finished running tool: /usr/local/go/bin/go tool vet /path/to/file .

which causes PROBLEMS tab to display messages regarding all the files in your workspace. 这会导致“问题”选项卡显示有关工作空间中所有文件的消息。

NOTE: also make sure go.lintOnSave and go.vetOnSave are set to package and not workspace . 注意:还要确保将go.lintOnSavego.vetOnSave设置为package而不是workspace You can turn off any of them by setting it to off 您可以通过将其设置为offoff任何一个

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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