Hacker News new | ask | show | jobs
by tandr 1472 days ago
There some file name conventions in place in Go [1]. Files ending in *_test.go are going to be run dufing `go test ` invocation, but not compiled during production build run. In general, last parts of file name reflect "tags", or a platform that this file should be built for. So, in the case of *_linux.go file will only be compiled when it targeted linux platform. Allows to have a file say file_windows_amd64.go and file_linux.go that have functions with same signature, but only one will be picked up for a target platform. Sort of like #ifdef , but at file-name level.

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...