2023-04-15 13:05:58 +08:00
|
|
|
package common
|
|
|
|
|
2023-05-27 06:53:58 +08:00
|
|
|
type EnvKeyType string
|
2023-04-15 13:05:58 +08:00
|
|
|
|
2023-05-27 06:53:58 +08:00
|
|
|
// EnvKey is a context key that can be used to set programmatically the environment
|
2023-04-15 13:05:58 +08:00
|
|
|
// gopsutil relies on to perform calls against the OS.
|
|
|
|
// Example of use:
|
|
|
|
//
|
2023-05-27 07:00:56 +08:00
|
|
|
// ctx := context.WithValue(context.Background(), common.EnvKey, EnvMap{common.HostProcEnvKey: "/myproc"})
|
2023-04-15 13:05:58 +08:00
|
|
|
// avg, err := load.AvgWithContext(ctx)
|
2023-05-27 06:53:58 +08:00
|
|
|
var EnvKey = EnvKeyType("env")
|
|
|
|
|
|
|
|
const (
|
|
|
|
HostProcEnvKey EnvKeyType = "HOST_PROC"
|
|
|
|
HostSysEnvKey EnvKeyType = "HOST_SYS"
|
|
|
|
HostEtcEnvKey EnvKeyType = "HOST_ETC"
|
2023-05-27 07:00:56 +08:00
|
|
|
HostVarEnvKey EnvKeyType = "HOST_VAR"
|
|
|
|
HostRunEnvKey EnvKeyType = "HOST_RUN"
|
|
|
|
HostDevEnvKey EnvKeyType = "HOST_DEV"
|
|
|
|
HostRootEnvKey EnvKeyType = "HOST_ROOT"
|
2023-05-27 06:53:58 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
type EnvMap map[EnvKeyType]string
|