Skip to content

Commit

Permalink
[host]darwin: PlatformInformation has been 5 values other is 4.
Browse files Browse the repository at this point in the history
  • Loading branch information
shirou committed Apr 6, 2017
1 parent 08ade55 commit e49a95f
Showing 1 changed file with 13 additions and 12 deletions.
25 changes: 13 additions & 12 deletions host/host_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,19 @@ func Info() (*InfoStat, error) {
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 {
ret.Platform = platform
ret.PlatformFamily = family
ret.PlatformVersion = pver
ret.KernelVersion = version
}

system, role, err := Virtualization()
Expand Down Expand Up @@ -140,19 +147,18 @@ func Users() ([]UserStat, error) {

}

func PlatformInformation() (string, string, string, string, error) {
func PlatformInformation() (string, string, string, error) {
platform := ""
family := ""
version := ""
pver := ""

sw_vers, err := exec.LookPath("sw_vers")
if err != nil {
return "", "", "", "", err
return "", "", "", err
}
uname, err := exec.LookPath("uname")
if err != nil {
return "", "", "", "", err
return "", "", "", err
}

out, err := invoke.Command(uname, "-s")
Expand All @@ -165,12 +171,7 @@ func PlatformInformation() (string, string, string, string, error) {
pver = strings.ToLower(strings.TrimSpace(string(out)))
}

out, err = invoke.Command(uname, "-r")
if err == nil {
version = strings.ToLower(strings.TrimSpace(string(out)))
}

return platform, family, pver, version, nil
return platform, family, pver, nil
}

func Virtualization() (string, string, error) {
Expand Down

0 comments on commit e49a95f

Please sign in to comment.