There’s a few guidelines to follow.
- File names that begin with “.” or “_” are ignored by the go tool
- Files with the suffix
_test.goare only compiled and run by thego testtool. - Files with os and architecture specific suffixes automatically follow those same constraints, e.g.
name_linux.gowill only build on linux,name_amd64.gowill only build on amd64. This is the same as having a//+build amd64line at the top of the file
See the go docs for more details: https://pkg.go.dev/cmd/go