[host]darwin: PlatformInformation has been 5 values other is 4.

tags/v2.17.03 v2.17.03
WAKAYAMA Shirou 8 years ago
parent 08ade552e3
commit e49a95f3d5

@ -32,12 +32,19 @@ func Info() (*InfoStat, error) {
ret.Hostname = hostname ret.Hostname = hostname
} }
platform, family, pver, version, err := PlatformInformation() uname, err := exec.LookPath("uname")
if err == nil {
out, err := invoke.Command(uname, "-r")
if err == nil {
ret.KernelVersion = strings.ToLower(strings.TrimSpace(string(out)))
}
}
platform, family, pver, err := PlatformInformation()
if err == nil { if err == nil {
ret.Platform = platform ret.Platform = platform
ret.PlatformFamily = family ret.PlatformFamily = family
ret.PlatformVersion = pver ret.PlatformVersion = pver
ret.KernelVersion = version
} }
system, role, err := Virtualization() system, role, err := Virtualization()
@ -140,19 +147,18 @@ func Users() ([]UserStat, error) {
} }
func PlatformInformation() (string, string, string, string, error) { func PlatformInformation() (string, string, string, error) {
platform := "" platform := ""
family := "" family := ""
version := ""
pver := "" pver := ""
sw_vers, err := exec.LookPath("sw_vers") sw_vers, err := exec.LookPath("sw_vers")
if err != nil { if err != nil {
return "", "", "", "", err return "", "", "", err
} }
uname, err := exec.LookPath("uname") uname, err := exec.LookPath("uname")
if err != nil { if err != nil {
return "", "", "", "", err return "", "", "", err
} }
out, err := invoke.Command(uname, "-s") out, err := invoke.Command(uname, "-s")
@ -165,12 +171,7 @@ func PlatformInformation() (string, string, string, string, error) {
pver = strings.ToLower(strings.TrimSpace(string(out))) pver = strings.ToLower(strings.TrimSpace(string(out)))
} }
out, err = invoke.Command(uname, "-r") return platform, family, pver, nil
if err == nil {
version = strings.ToLower(strings.TrimSpace(string(out)))
}
return platform, family, pver, version, nil
} }
func Virtualization() (string, string, error) { func Virtualization() (string, string, error) {

Loading…
Cancel
Save