提交 413cb32b 编写于 作者: L Laurie Clark-Michalek

Use static initialisation for invoke instances, instead of init funcs

The order of init function execution is dependant on the order that the
source files are passed to the compiler. This causes issues when
building under other build systems, such as bazel or buck, as they are
not guarenteed to maintain the same file order as the default go tool.
上级 6b5767f1
......@@ -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)
......
......@@ -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"`
......
......@@ -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"`
......
......@@ -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.
......
......@@ -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"`
......
......@@ -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.
......
......@@ -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
......
......@@ -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"`
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册