Hello,
Just throwing out an idea to see if others might find it useful. I
frequently find myself writing two separate versions of
system-specific code; one for Windows and one for POSIX systems. The
way I typically achieve is by naming the POSIX version xyz.go and the
windows version xyz_windows.go. The POSIX version has to have the
following build constraint in the file:
// +build !windows
I think it would be better if there was a special '_other' suffix that
could be added to files. A file named xyz_other.go is compiled only if
no other xyz_*.go files are applicable to the current environment.
This makes the intention clear, because with xyz.go and xyz_windows.go
you can't immediately tell if the latter is adding some extra code on
Windows or if the two are mutually exclusive. It also simplifies the
process for adding new system- or architecture-specific code. If, at
some later point, I decide that FreeBSD needs special handling, I can
add xyz_freebsd.go without having to modify the +build line in xyz.go.
Thoughts?
- Max
--