From bce9212defc9cc9e0183b8fccae8b1f991977745 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Fri, 1 Apr 2016 22:22:03 +0900 Subject: [PATCH] fix build bugs. --- cpu/cpu_linux.go | 2 +- host/host_linux.go | 2 +- internal/common/common_darwin.go | 2 +- internal/common/common_freebsd.go | 2 +- mem/mem_darwin.go | 3 --- net/net_darwin.go | 2 +- process/process_posix.go | 4 ++-- 7 files changed, 7 insertions(+), 10 deletions(-) diff --git a/cpu/cpu_linux.go b/cpu/cpu_linux.go index c561f66..f7cf4c3 100644 --- a/cpu/cpu_linux.go +++ b/cpu/cpu_linux.go @@ -19,7 +19,7 @@ func init() { if err != nil { return } - out, err := exec.Command(getcon, "CLK_TCK").Output() + out, err := exec.Command(getconf, "CLK_TCK").Output() // ignore errors if err == nil { i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64) diff --git a/host/host_linux.go b/host/host_linux.go index 3ae232a..f56906c 100644 --- a/host/host_linux.go +++ b/host/host_linux.go @@ -165,7 +165,7 @@ func getLSB() (*LSB, error) { } else if common.PathExists("/usr/bin/lsb_release") { lsb_release, err := exec.LookPath("/usr/bin/lsb_release") if err != nil { - return ret, error + return ret, err } out, err := exec.Command(lsb_release).Output() if err != nil { diff --git a/internal/common/common_darwin.go b/internal/common/common_darwin.go index 2b795d8..bdad369 100644 --- a/internal/common/common_darwin.go +++ b/internal/common/common_darwin.go @@ -18,7 +18,7 @@ func DoSysctrl(mib string) ([]string, error) { sysctl, err := exec.LookPath("/usr/bin/getconf") if err != nil { - return + return []string{}, err } out, err := exec.Command(sysctl, "-n", mib).Output() if err != nil { diff --git a/internal/common/common_freebsd.go b/internal/common/common_freebsd.go index 6408a97..dfdcebd 100644 --- a/internal/common/common_freebsd.go +++ b/internal/common/common_freebsd.go @@ -17,7 +17,7 @@ func DoSysctrl(mib string) ([]string, error) { } sysctl, err := exec.LookPath("/sbin/sysctl") if err != nil { - return + return []string{}, err } out, err := exec.Command(sysctl, "-n", mib).Output() if err != nil { diff --git a/mem/mem_darwin.go b/mem/mem_darwin.go index acf9a5f..922b05c 100644 --- a/mem/mem_darwin.go +++ b/mem/mem_darwin.go @@ -4,7 +4,6 @@ package mem import ( "encoding/binary" - "fmt" "strconv" "strings" "syscall" @@ -36,8 +35,6 @@ func SwapMemory() (*SwapMemoryStat, error) { return ret, err } - fmt.Println(swapUsage) - total := strings.Replace(swapUsage[2], "M", "", 1) used := strings.Replace(swapUsage[5], "M", "", 1) free := strings.Replace(swapUsage[8], "M", "", 1) diff --git a/net/net_darwin.go b/net/net_darwin.go index 7a5de45..4fa358a 100644 --- a/net/net_darwin.go +++ b/net/net_darwin.go @@ -17,7 +17,7 @@ import ( // lo0 16384 ::1/128 ::1 869107 - 169411755 869107 - 169411755 - - // lo0 16384 127 127.0.0.1 869107 - 169411755 869107 - 169411755 - - func IOCounters(pernic bool) ([]IOCountersStat, error) { - netstat, err := exec.LookPath("/usr/bin/netstat") + netstat, err := exec.LookPath("/usr/sbin/netstat") if err != nil { return nil, err } diff --git a/process/process_posix.go b/process/process_posix.go index 20db9e4..92353b8 100644 --- a/process/process_posix.go +++ b/process/process_posix.go @@ -66,11 +66,11 @@ func (p *Process) SendSignal(sig syscall.Signal) error { kill, err := exec.LookPath("kill") if err != nil { - return + return err } cmd := exec.Command(kill, "-s", sigAsStr, strconv.Itoa(int(p.Pid))) cmd.Stderr = os.Stderr - err := cmd.Run() + err = cmd.Run() if err != nil { return err }