Get or check the current macOS version in Go.
$ go get github.com/wobsoriano/go-macos-version
package main
import (
"fmt"
mac "github.com/wobsoriano/go-macos-version"
)
func main() {
version, err := mac.MacOSVersion()
// => "10.2.3"
matches, err := mac.IsMacOSVersion(">10.10")
// => true
mac.AssertMacOSVersion(">=10.12.5")
// Error: Requires macOS >=10.12.5
mac.AssertMacOS()
// Error: Requires macOS
if mac.IsMacOS {
fmt.Println("macOS")
}
}
Returns the macOS version or an error if the platform is not macOS.
Returns a bool
if whether the specified semver range matches the macOS version or an error if there is an issue parsing the version.
Throws an error if the specified semver range does not match the macOS version.
Throws an error if the platform is not macOS.
Type: bool
Whether the platform is macOS.
https://github.com/sindresorhus/macos-version
MIT