Home > Backend Development > Golang > How to Exclude Vendor Packages When Running Go Tests?

How to Exclude Vendor Packages When Running Go Tests?

DDD
Release: 2024-12-07 08:08:12
Original
758 people have browsed it

How to Exclude Vendor Packages When Running Go Tests?

Go: Running Tests Excluding Vendor Packages

Many projects utilize the vendor folder to store external dependencies, which can sometimes lead to unwanted inclusion in tests. This article explores how to run Go tests on all test files except for those within the vendor package.

Various approaches have been attempted, such as using the -run option with a regex pattern. However, this method may encounter issues due to pattern matching limitations.

Fortunately, a simpler solution is available in Go 1.9 and later. The ... wildcard now excludes the ./vendor directory, making it easy to run tests on all other files:

go test ./...
Copy after login

This command will effectively run tests on all test files (e.g., foobar_test.go) excluding those located within the ./vendor directory.

The above is the detailed content of How to Exclude Vendor Packages When Running Go Tests?. 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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template