Last active
March 7, 2021 04:45
-
-
Save svalleru/e33e221878fe9a44c547 to your computer and use it in GitHub Desktop.
Detect OS in Go
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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