From 0d60c8356c42551caf1b68bf5dae783254183d72 Mon Sep 17 00:00:00 2001 From: deltax Date: Fri, 1 Jun 2018 12:33:11 +0200 Subject: [PATCH 1/3] Quick fix for #105 - add lsb_release because sw_vers doesn't work on linux - add system check --- system/system_info.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/system/system_info.go b/system/system_info.go index d255bde4..7526570a 100644 --- a/system/system_info.go +++ b/system/system_info.go @@ -18,7 +18,15 @@ func NewSystemInfo() *SystemInfo { arg := []string{} - cmd := exec.Command("sw_vers", arg...) + switch runtime.GOOS { + case "linux": + cmd := exec.Command("lsb_release -a", arg...) + case "darwin": + cmd := exec.Command("sw_vers", arg...) + default: + return "" + } + raw := wtf.ExecuteCommand(cmd) for _, row := range strings.Split(raw, "\n") { From 53c1a7938c4392a4fa3478f3f80b4a4c63937c3e Mon Sep 17 00:00:00 2001 From: deltax Date: Fri, 1 Jun 2018 17:57:41 +0200 Subject: [PATCH 2/3] Update system_info.go --- system/system_info.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/system/system_info.go b/system/system_info.go index 7526570a..21ee60f1 100644 --- a/system/system_info.go +++ b/system/system_info.go @@ -20,11 +20,11 @@ func NewSystemInfo() *SystemInfo { switch runtime.GOOS { case "linux": - cmd := exec.Command("lsb_release -a", arg...) + cmd := exec.Command("uname -a", arg...) case "darwin": cmd := exec.Command("sw_vers", arg...) default: - return "" + cmd := exec.Command("sw_vers", arg...) } raw := wtf.ExecuteCommand(cmd) From 225094c978d5ae55802d1394f52abee32b7a2004 Mon Sep 17 00:00:00 2001 From: Chris Cummer Date: Fri, 1 Jun 2018 09:13:21 -0700 Subject: [PATCH 3/3] Add a missing require and a missing var declaration to system_info.go --- system/system_info.go | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/system/system_info.go b/system/system_info.go index 21ee60f1..6773fe0e 100644 --- a/system/system_info.go +++ b/system/system_info.go @@ -2,6 +2,7 @@ package system import ( "os/exec" + "runtime" "strings" "github.com/senorprogrammer/wtf/wtf" @@ -18,13 +19,14 @@ func NewSystemInfo() *SystemInfo { arg := []string{} + var cmd *exec.Cmd switch runtime.GOOS { case "linux": - cmd := exec.Command("uname -a", arg...) + cmd = exec.Command("uname -a", arg...) case "darwin": - cmd := exec.Command("sw_vers", arg...) + cmd = exec.Command("sw_vers", arg...) default: - cmd := exec.Command("sw_vers", arg...) + cmd = exec.Command("sw_vers", arg...) } raw := wtf.ExecuteCommand(cmd)