当我运行这个命令时:
go test -tags integration $(go list ./... | grep -v /vendor/)
go测试失败,因为有些软件包的所有测试都标有:// +build !integration
can't load package: build constraints exclude all Go files
在这种情况下,有没有一种方法可以让 go test 忽略这些包?谢谢!
当我运行这个命令时:
go test -tags integration $(go list ./... | grep -v /vendor/)
go测试失败,因为有些软件包的所有测试都标有:// +build !integration
can't load package: build constraints exclude all Go files
在这种情况下,有没有一种方法可以让 go test 忽略这些包?谢谢!
You will only get that error if all the files in the package are excluded by your build constraints, not just the test files. If that's what you want, just add a single package file with no code and the package will still be able to be loaded. For example, many packages put their package level docs in a separate file, which you could use to always have a valid package:
// Package foo does foo
package foo