Problem:
A project folder contains a mix of components and vendor packages. The goal is to execute Go tests on all test files (e.g., foobar_test.go) except those within the vendor directory using the go test command.
Solution:
The go test command includes the -run flag, which allows specifying a regular expression to match the desired test identifiers. However, matching based on filenames can be problematic.
Starting with Go 1.9, the ... wildcard in go test now excludes the ./vendor directory. Therefore, the following command should suffice:
go test ./...
This will execute all tests except those within the ./vendor directory.
The above is the detailed content of How Can I Run Go Tests on All Files Except Those in the Vendor Directory?. For more information, please follow other related articles on the PHP Chinese website!