Skipping Test Files on Go Versions Below 1.5
To skip a test file if it is run on systems with Go 1.4 and below, leverage build constraints.
The build constraint is a directive that instructs the Go compiler to build a package only if certain criteria are met. In this case, we want to build the test file only if the Go version is 1.5 or higher.
To specify the build constraint, add the following line at the beginning of the test file:
// +build go1.5
This constraint ensures that the file is compiled and tested only when the Go version is 1.5 and onward.
1 // +build go1.5 2 3 package yourpackage
Important Notes:
// +build go1.6
The above is the detailed content of How Can I Skip Go Test Files on Versions Below 1.5?. For more information, please follow other related articles on the PHP Chinese website!