From efdfa8d119cd1c1fe4d202ad575f58eaab7e4d81 Mon Sep 17 00:00:00 2001 From: liyiheng Date: Sat, 2 Jun 2018 11:41:30 +0800 Subject: [PATCH 1/2] Update system_info.go --- system/system_info.go | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/system/system_info.go b/system/system_info.go index 6773fe0e..6c51b197 100644 --- a/system/system_info.go +++ b/system/system_info.go @@ -28,7 +28,7 @@ func NewSystemInfo() *SystemInfo { default: cmd = exec.Command("sw_vers", arg...) } - + raw := wtf.ExecuteCommand(cmd) for _, row := range strings.Split(raw, "\n") { @@ -41,11 +41,27 @@ func NewSystemInfo() *SystemInfo { m[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) } - sysInfo := SystemInfo{ - ProductName: m["ProductName"], - ProductVersion: m["ProductVersion"], - BuildVersion: m["BuildVersion"], - } + sysInfo := new(SystemInfo) + switch runtime.GOOS { + case "linux": + sysInfo = &SystemInfo{ + ProductName: m["Distributor ID"], + ProductVersion: m["Description"], + BuildVersion: m["Release"], + } + case "darwin": + sysInfo = &SystemInfo{ + ProductName: m["ProductName"], + ProductVersion: m["ProductVersion"], + BuildVersion: m["BuildVersion"], + } + default: + sysInfo = &SystemInfo{ + ProductName: m["ProductName"], + ProductVersion: m["ProductVersion"], + BuildVersion: m["BuildVersion"], + } - return &sysInfo + } + return sysInfo } From 12c86936614b76bb7b130a0b6346662bfefbe8a9 Mon Sep 17 00:00:00 2001 From: liyiheng Date: Sat, 2 Jun 2018 11:43:50 +0800 Subject: [PATCH 2/2] Update system_info.go --- system/system_info.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system/system_info.go b/system/system_info.go index 6c51b197..63fa6770 100644 --- a/system/system_info.go +++ b/system/system_info.go @@ -41,7 +41,7 @@ func NewSystemInfo() *SystemInfo { m[strings.TrimSpace(parts[0])] = strings.TrimSpace(parts[1]) } - sysInfo := new(SystemInfo) + var sysInfo *SystemInfo switch runtime.GOOS { case "linux": sysInfo = &SystemInfo{