go - 如何在运行“go test”时排除或跳过特定目录
问题描述
go test $(go list ./... | grep -v /vendor/) -coverprofile .testCoverage.txt
我正在使用上述命令来测试文件,但是我想从测试中排除 1 个名为“Store”的文件夹。怎么做?
解决方案
你已经在这样做了:
$(go list ./... | grep -v /vendor/)
该grep -v /vendor/
部分是排除/vendor/
目录。因此,只需对您的Store
目录执行相同操作:
go test $(go list ./... | grep -v /Store/) -coverprofile .testCoverage.txt
请注意,/vendor/
不需要排除这种方式(除非您使用的是非常旧的 Go 版本)。如果您使用的是旧版本的 Go,您可以将它们组合起来:
go test $(go list ./... | grep -v /vendor/ | grep -v /Store/) -coverprofile .testCoverage.txt
推荐阅读
- typescript - 如何在 Typescript 中声明一个全局的 globalThis?
- python - Proper way to update pandas dataframe column with function having other columns as arguments
- javascript - Test whether every element of array is truthy
- php - How to append data obtained from database to array?
- python - 列表不应该是空的
- multer - 使用 multer 上传文件
- firebase - 在每个屏幕上的 fcm 通知上显示小吃栏
- grep - grep 用于具有特殊字符的模式并仅输出匹配的字符串
- scala - 如何查看 Scala 用于为案例类自动生成 apply 函数的代码?
- javascript - Can you tell moment.js what time zone a value is in?