如何在运行“ go test”时排除或跳过特定目录

时间:2019-03-18 15:17:13

标签: go testing goland

go test $(go list ./... | grep -v /vendor/) -coverprofile .testCoverage.txt

我正在使用上面的命令来测试文件,但是我想从测试中排除1个名为“ Store”的文件夹。怎么做?

1 个答案:

答案 0 :(得分:0)

您已经在做

AddressSanitizer: heap-use-after-free on address 0x6020000001b0 at pc 0x00000040171c bp 0x7ffff6ca1190 sp 0x7ffff6ca1188

$(go list ./... | grep -v /vendor/) 部分将排除grep -v /vendor/目录。因此,只需对您的/vendor/目录执行相同操作:

Store

请注意,不必以这种方式排除go test $(go list ./... | grep -v /Store/) -coverprofile .testCoverage.txt (除非您使用的是Go的真正旧版本)。如果您使用的是旧版的Go,可以将它们组合在一起:

/vendor/