[host][darwin] Fix #574, use 'uname -r' in KernelVersion()

This commit is contained in:
Lomanic 2018-09-01 17:23:39 +02:00
parent eb1f1ab16f
commit 18b2744df2
1 changed files with 11 additions and 6 deletions

View File

@ -38,12 +38,9 @@ func InfoWithContext(ctx context.Context) (*InfoStat, error) {
ret.Hostname = hostname
}
uname, err := exec.LookPath("uname")
kernelVersion, err := KernelVersionWithContext(ctx)
if err == nil {
out, err := invoke.CommandWithContext(ctx, uname, "-r")
if err == nil {
ret.KernelVersion = strings.ToLower(strings.TrimSpace(string(out)))
}
ret.KernelVersion = kernelVersion
}
platform, family, pver, err := PlatformInformation()
@ -214,7 +211,15 @@ func KernelVersion() (string, error) {
}
func KernelVersionWithContext(ctx context.Context) (string, error) {
_, _, version, err := PlatformInformation()
uname, err := exec.LookPath("uname")
if err != nil {
return "", err
}
out, err := invoke.CommandWithContext(ctx, uname, "-r")
if err != nil {
return "", err
}
version := strings.ToLower(strings.TrimSpace(string(out)))
return version, err
}