From 18b2744df2559c76e11b80c8e829bc7564d7b887 Mon Sep 17 00:00:00 2001 From: Lomanic Date: Sat, 1 Sep 2018 17:23:39 +0200 Subject: [PATCH] [host][darwin] Fix #574, use 'uname -r' in KernelVersion() --- host/host_darwin.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/host/host_darwin.go b/host/host_darwin.go index 5a4066a..8241fc0 100644 --- a/host/host_darwin.go +++ b/host/host_darwin.go @@ -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 }