separate struct and func due to the lack of syscall on windows.
This commit is contained in:
parent
f16e9efb2e
commit
4ffbd2a28f
24
host.go
24
host.go
|
@ -1,10 +1,5 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"syscall"
|
||||
)
|
||||
|
||||
type Host struct{}
|
||||
|
||||
type HostInfo struct {
|
||||
|
@ -17,22 +12,3 @@ func NewHost() Host {
|
|||
h := Host{}
|
||||
return h
|
||||
}
|
||||
|
||||
func (h Host) HostInfo() (HostInfo, error) {
|
||||
ret := HostInfo{}
|
||||
sysinfo := &syscall.Sysinfo_t{}
|
||||
|
||||
if err := syscall.Sysinfo(sysinfo); err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
hostname, err := os.Hostname()
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
ret.Hostname = hostname
|
||||
ret.Uptime = sysinfo.Uptime
|
||||
ret.Procs = uint64(sysinfo.Procs)
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue