I am using the +build
tag to define what to compile based on the architecture.
For code that only runs on UNIX/BSD I use this:
// +build freebsd netbsd openbsd dragonfly darwin
// +build amd64
And for linux I have:
// +build linux
The name of the files containing the source code is like this:
watchpid.go
watchpid_linux.go
The files contains the same method signature but different approaches.
func watchPid() {
// kqueue for UNIX, BSD
// for loop cross-platform version (linux)
}
In case I would like to test/compile for example the linux version on a Mac OS X, is there a easy switch/trick to do it instead of editing the +build
tag or renaming the files?