Merge pull request #502 from lclarkmichalek/master

Use static initialisation for invoke instances, instead of init funcs
pull/503/head
shirou 7 years ago committed by GitHub
commit 12394ccbca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -54,10 +54,9 @@ type lastPercent struct {
} }
var lastCPUPercent lastPercent var lastCPUPercent lastPercent
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() { func init() {
invoke = common.Invoke{}
lastCPUPercent.Lock() lastCPUPercent.Lock()
lastCPUPercent.lastCPUTimes, _ = Times(false) lastCPUPercent.lastCPUTimes, _ = Times(false)
lastCPUPercent.lastPerCPUTimes, _ = Times(true) lastCPUPercent.lastPerCPUTimes, _ = Times(true)

@ -6,11 +6,7 @@ import (
"github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/internal/common"
) )
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
type UsageStat struct { type UsageStat struct {
Path string `json:"path"` Path string `json:"path"`

@ -10,11 +10,7 @@ import (
var ErrDockerNotAvailable = errors.New("docker not available") var ErrDockerNotAvailable = errors.New("docker not available")
var ErrCgroupNotAvailable = errors.New("cgroup not available") var ErrCgroupNotAvailable = errors.New("cgroup not available")
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
type CgroupMemStat struct { type CgroupMemStat struct {
ContainerID string `json:"containerID"` ContainerID string `json:"containerID"`

@ -6,11 +6,7 @@ import (
"github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/internal/common"
) )
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
// A HostInfoStat describes the host status. // A HostInfoStat describes the host status.
// This is not in the psutil but it useful. // This is not in the psutil but it useful.

@ -6,11 +6,7 @@ import (
"github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/internal/common"
) )
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
type AvgStat struct { type AvgStat struct {
Load1 float64 `json:"load1"` Load1 float64 `json:"load1"`

@ -6,11 +6,7 @@ import (
"github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/internal/common"
) )
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
// Memory usage statistics. Total, Available and Used contain numbers of bytes // Memory usage statistics. Total, Available and Used contain numbers of bytes
// for human consumption. // for human consumption.

@ -12,11 +12,7 @@ import (
"github.com/shirou/gopsutil/internal/common" "github.com/shirou/gopsutil/internal/common"
) )
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
type IOCountersStat struct { type IOCountersStat struct {
Name string `json:"name"` // interface name Name string `json:"name"` // interface name

@ -11,11 +11,7 @@ import (
"github.com/shirou/gopsutil/mem" "github.com/shirou/gopsutil/mem"
) )
var invoke common.Invoker var invoke common.Invoker = common.Invoke{}
func init() {
invoke = common.Invoke{}
}
type Process struct { type Process struct {
Pid int32 `json:"pid"` Pid int32 `json:"pid"`

Loading…
Cancel
Save