问题描述
我正在尝试在项目中实现 dep
。这一切都很好,但是它还添加了一个供应商目录。现在,我需要更新工具以忽略此目录,否则我的供应商软件包将被修改,或者得到警告的误报。我当前正在使用以下工具:
I am trying to implement dep
in my project. This is all working well but it also adds a vendor directory. I now need to update my tooling to ignore this directory or my vendored packages will be modified or I get false positives of warnings. I am currently using the following tooling:
- goimports -w
- go vet
- 棉绒
这些工具也用于CI。我确实想继续使用goimports进行自动格式化,但是我愿意开始使用gometalinter。我并不是真正在寻找使用grep的解决方案并找到魔术。
These tools are also used in CI. I do want to keep autoformatting using goimports, but I am willing to start using gometalinter. I am not really looking for a solution using grep and find magic.
如何使这些工具忽略 vendor /
?
推荐答案
gometalinter具有 --vendor标志,可忽略供应商文件夹。
gometalinter has a "--vendor" flag to ignore the vendor folder. the flag passes the needed paramters to the underlying tools to ignore the folder.
所以一个解决方案是只使用govet,golint和goimports以及gometalinter
so one solution would be to use only govet, golint und goimports with gometalinter
gometalinter --disable-all --enable=vet --enable=golint --enable=goimports --vendor ./...
另一个解决方案可能是(从):
another solution might be (copied from gist):
goimports -d $(find . -type f -name '*.go' -not -path "./vendor/*")
imho I会首选第一个解决方案。这样,您可以根据需要轻松添加其他短绒。
imho I would prefer the first solution. That way you could easily add other linters as needed.
这篇关于goimports需要忽略供应商软件包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!