Home >Backend Development >Golang >How Can I Run Go Tests and Exclude Vendor Packages?
Running Go Tests Excluding Vendor Packages
To run Go tests on all test files in your project while excluding the test files in the vendor package, you can follow these steps:
In the documentation, you can pass a regex to the -run option to specify which tests to run. However, matching the regex against the test identifier (not the filename) presents some challenges.
For instance, go test ./* will result in can't load package errors. Instead, you can exclude the vendor directory using the ... wildcard, introduced in Go 1.9.
To execute Go tests on all test files except those in the vendor package, simply run:
go test ./...
This command will exclude the ./vendor directory from the list of test files to be executed.
The above is the detailed content of How Can I Run Go Tests and Exclude Vendor Packages?. For more information, please follow other related articles on the PHP Chinese website!