Home > Backend Development > Golang > How Can I Run Go Tests on All Files Except Those in the Vendor Directory?

How Can I Run Go Tests on All Files Except Those in the Vendor Directory?

Linda Hamilton
Release: 2024-12-11 08:32:10
Original
828 people have browsed it

How Can I Run Go Tests on All Files Except Those in the Vendor Directory?

Running Go Tests on All Non-Vendor Test Files

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

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!

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