From d0da149b67121d7b2d5daf84edc8ef295a99a4c8 Mon Sep 17 00:00:00 2001 From: Shirou WAKAYAMA Date: Tue, 22 Apr 2014 09:48:48 +0900 Subject: [PATCH] implements Uptime. --- host_unix.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/host_unix.go b/host_unix.go index 49e4975..0fdb1f6 100644 --- a/host_unix.go +++ b/host_unix.go @@ -9,8 +9,17 @@ import ( func (h Host) HostInfo() (HostInfo, error) { ret := HostInfo{} + hostname, err := os.Hostname() ret.Hostname = hostname + if err != nil { + return ret, err + } + + sysinfo := &syscall.Sysinfo_t{} + if err := syscall.Sysinfo(sysinfo); err != nil { + return ret, err + } ret.Uptime = sysinfo.Uptime return ret, nil -- GitLab