gosal
gosal copied to clipboard
Implement OS Switch
need to put a switch in that does something like
switch os := runtime.GOOS; os {
case "darwin":
fmt.Println("darwin.")
case "windows":
fmt.Println("windows.")
Example https://github.com/kolide/launcher/blob/fb08499f16d5fad96a545453f13ddfc2c70148cb/osquery/platform.go
I've been thinking about this. What you want (most likely) is to use build tags to only compile windows code for exe
and macos code for darwin binaries. Go has a quick shortcut for this. Basically any file that ends with _windows.go
will only compile for windows and _darwin.go
will only compile for mac. That can be used here by having a single function in reports like BuildReport() *Report
which implemented three times in _darwin
, _linux
and _windows.go
.
Also agree about using the build tags. The file name approach is way more common and easier than using the // +windows header syntax.
That case statement might be required later but that’s only helpful for runtime vs buildtime.