Skip to content

Instantly share code, notes, and snippets.

@svalleru
Last active March 7, 2021 04:45
Show Gist options
  • Save svalleru/e33e221878fe9a44c547 to your computer and use it in GitHub Desktop.
Save svalleru/e33e221878fe9a44c547 to your computer and use it in GitHub Desktop.
Detect OS in Go
package main
import "fmt"
import "runtime"
func main() {
fmt.Println("OS Detected: ", runtime.GOOS)
switch os := runtime.GOOS; os {
case "darwin":
fmt.Println("Mac OS Hipster")
case "linux":
fmt.Println("Linux Geek")
default:
fmt.Println("Other")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment