diff --git a/cpu/cpu.go b/cpu/cpu.go index 049869e2..ceaf77fe 100644 --- a/cpu/cpu.go +++ b/cpu/cpu.go @@ -54,10 +54,9 @@ type lastPercent struct { } var lastCPUPercent lastPercent -var invoke common.Invoker +var invoke common.Invoker = common.Invoke{} func init() { - invoke = common.Invoke{} lastCPUPercent.Lock() lastCPUPercent.lastCPUTimes, _ = Times(false) lastCPUPercent.lastPerCPUTimes, _ = Times(true) diff --git a/disk/disk.go b/disk/disk.go index a2c47204..1c31047d 100644 --- a/disk/disk.go +++ b/disk/disk.go @@ -6,11 +6,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} type UsageStat struct { Path string `json:"path"` diff --git a/docker/docker.go b/docker/docker.go index 83716fdc..76791c2a 100644 --- a/docker/docker.go +++ b/docker/docker.go @@ -10,11 +10,7 @@ import ( var ErrDockerNotAvailable = errors.New("docker not available") var ErrCgroupNotAvailable = errors.New("cgroup not available") -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} type CgroupMemStat struct { ContainerID string `json:"containerID"` diff --git a/host/host.go b/host/host.go index a256a6c8..1e9e9bb6 100644 --- a/host/host.go +++ b/host/host.go @@ -6,11 +6,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} // A HostInfoStat describes the host status. // This is not in the psutil but it useful. diff --git a/load/load.go b/load/load.go index dfe32a1e..90858895 100644 --- a/load/load.go +++ b/load/load.go @@ -6,11 +6,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} type AvgStat struct { Load1 float64 `json:"load1"` diff --git a/mem/mem.go b/mem/mem.go index 87dfb53b..bdf15ba5 100644 --- a/mem/mem.go +++ b/mem/mem.go @@ -6,11 +6,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} // Memory usage statistics. Total, Available and Used contain numbers of bytes // for human consumption. diff --git a/net/net.go b/net/net.go index 428e68e1..c31f5124 100644 --- a/net/net.go +++ b/net/net.go @@ -12,11 +12,7 @@ import ( "github.com/shirou/gopsutil/internal/common" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} type IOCountersStat struct { Name string `json:"name"` // interface name diff --git a/process/process.go b/process/process.go index e20742a5..29d114ea 100644 --- a/process/process.go +++ b/process/process.go @@ -11,11 +11,7 @@ import ( "github.com/shirou/gopsutil/mem" ) -var invoke common.Invoker - -func init() { - invoke = common.Invoke{} -} +var invoke common.Invoker = common.Invoke{} type Process struct { Pid int32 `json:"pid"`