> if I name my source file i_love_linux.go, it won’t get compiled on my Mac
What the fuck?
What the fuck?
There is a way to specify what file is actually targeting inside the file, through //go: "pragmas" too
[1] https://stackoverflow.com/questions/25161774/what-are-conven...
Now a bit more background, this goes back to C and C++, and is considered a best practice to name translation units as name_os_arch or similar pattern, with the header file being only name, instead of #ifdef spaghetti.
This is actually one of the few things I think Go did right.
...seriously wtf
It will catch someone out who uses BSD as an acronym for something in their domain model (Bulk Sales Discount?) then xyz_bsd.go doesn't compile.
If a file's name, after stripping the extension and a possible _test suffix, matches any of the following patterns:
*_GOOS
*_GOARCH
\*_GOOS_GOARCH
(example: source_windows_amd64.go) where GOOS and GOARCH represent any known operating system and architecture values respectively, then the file is considered to have an implicit build constraint requiring those terms (in addition to any explicit constraints in the file).