David K. Bainbridge | 528b318 | 2017-01-23 08:51:59 -0800 | [diff] [blame^] | 1 | // Copyright 2015 Canonical Ltd. |
| 2 | // Licensed under the LGPLv3, see LICENCE file for details. |
| 3 | |
| 4 | package utils |
| 5 | |
| 6 | // These are the names of the operating systems recognized by Go. |
| 7 | const ( |
| 8 | OSWindows = "windows" |
| 9 | OSDarwin = "darwin" |
| 10 | OSDragonfly = "dragonfly" |
| 11 | OSFreebsd = "freebsd" |
| 12 | OSLinux = "linux" |
| 13 | OSNacl = "nacl" |
| 14 | OSNetbsd = "netbsd" |
| 15 | OSOpenbsd = "openbsd" |
| 16 | OSSolaris = "solaris" |
| 17 | ) |
| 18 | |
| 19 | // OSUnix is the list of unix-like operating systems recognized by Go. |
| 20 | // See http://golang.org/src/path/filepath/path_unix.go. |
| 21 | var OSUnix = []string{ |
| 22 | OSDarwin, |
| 23 | OSDragonfly, |
| 24 | OSFreebsd, |
| 25 | OSLinux, |
| 26 | OSNacl, |
| 27 | OSNetbsd, |
| 28 | OSOpenbsd, |
| 29 | OSSolaris, |
| 30 | } |
| 31 | |
| 32 | // OSIsUnix determines whether or not the given OS name is one of the |
| 33 | // unix-like operating systems recognized by Go. |
| 34 | func OSIsUnix(os string) bool { |
| 35 | for _, goos := range OSUnix { |
| 36 | if os == goos { |
| 37 | return true |
| 38 | } |
| 39 | } |
| 40 | return false |
| 41 | } |