mirror of https://github.com/shirou/gopsutil
change to use a typed map per code review
parent
5b9212e240
commit
0cbdf257ab
@ -1,11 +1,19 @@
|
|||||||
package common
|
package common
|
||||||
|
|
||||||
type envKey string
|
type EnvKeyType string
|
||||||
|
|
||||||
// Env is a context key that can be used to set programmatically the environment
|
// EnvKey is a context key that can be used to set programmatically the environment
|
||||||
// gopsutil relies on to perform calls against the OS.
|
// gopsutil relies on to perform calls against the OS.
|
||||||
// Example of use:
|
// Example of use:
|
||||||
//
|
//
|
||||||
// ctx := context.WithValue(context.Background(), Env, map[string]string{"HOST_PROC": "/myproc"})
|
// ctx := context.WithValue(context.Background(), common.EnvKey, EnvMap{"HOST_PROC": "/myproc"})
|
||||||
// avg, err := load.AvgWithContext(ctx)
|
// avg, err := load.AvgWithContext(ctx)
|
||||||
var Env = envKey("env")
|
var EnvKey = EnvKeyType("env")
|
||||||
|
|
||||||
|
const (
|
||||||
|
HostProcEnvKey EnvKeyType = "HOST_PROC"
|
||||||
|
HostSysEnvKey EnvKeyType = "HOST_SYS"
|
||||||
|
HostEtcEnvKey EnvKeyType = "HOST_ETC"
|
||||||
|
)
|
||||||
|
|
||||||
|
type EnvMap map[EnvKeyType]string
|
||||||
|
Loading…
Reference in New Issue