In Go, filenames have semantic meaning. For example:
*_windows.go // Only include in compilations for Windows
*_unix.go // Only include in compilations for Unix
*_386.go // Only include in compilations for 386 systems
*_test.go // Only include when run with `go test`
However, I can't seem to get the following to work:
*_windows_test.go // Only include when running `go test` on windows
*_test_windows.go // Another attempt
Is this even possible with Go? If so, how?
Just use a build constraint on the test files.
// +build windows
A build constraint is evaluated as the OR of space-separated options; each option evaluates as the AND of its comma-separated terms; and each term is an alphanumeric word or, preceded by !, its negation. That is, the build constraint:
Turns out I was wrong. It does work. The issue was that I also had a file called foo_unix_test.go
, and apparently Go doesn't support the *_unix.go
syntax as a special case.