Home > Backend Development > Golang > How Can I Run Go Tests and Exclude Vendor Packages?

How Can I Run Go Tests and Exclude Vendor Packages?

Patricia Arquette
Release: 2024-12-11 02:09:14
Original
551 people have browsed it

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 ./...
Copy after login

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!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template