Files
go_sysutils/envs/types.go
2025-12-06 19:19:53 -05:00

42 lines
1.7 KiB
Go

package envs
import (
"sync"
"github.com/shirou/gopsutil/v4/process"
)
type (
/*
EnvErrNoVal is an error containing the variable that does not exist
(and information surrounding the errored state).
*/
EnvErrNoVal struct {
// VarName is the variable name/key name originally specified in the function call.
VarName string `json:"var" toml:"VariableName" yaml:"Variable Name/Key" xml:"key,attr"`
// WasFound is only used for GetEnvErrNoBlank(). It is true if the variable was found/populated.
WasFound bool `json:"found" toml:"Found" yaml:"Found" xml:"found,attr"`
// WasRequiredNonEmpty indicates that this error was returned in a context where a variable was required to be non-empty (e.g. via GetEnvErrNoBlank()) but was empty.
WasRequiredNonEmpty bool `json:"reqd_non_empty" toml:"RequiredNonEmpty" yaml:"Required Non-Empty" xml:"reqNonEmpty,attr"`
// IgnoreWhitespace is true if the value was found but its evaluation was done against a whitestripped version.
IgnoreWhitespace bool `json:"ignore_ws" toml:"IgnoreWhitespace" yaml:"Ignore Whitespace" xml:"ignoreWhitespace,attr"`
// WasWhitespace is true if the value was whitespace-only.
WasWhitespace bool `json:"was_ws" toml:"WasWhitespace" yaml:"Was Whitespace Only" xml:"wasWhitespace,attr"`
}
/*
StaticEnv is an environment variable mapping that duplicates the normal functions of the standalone functions
but can be used for other processes, mock tests, etc.
(The standalone functions actually perform the same functions on the default StaticEnv as returned from [Current].)
*/
StaticEnv struct {
dynamic bool
strict bool
envVars map[string]string
self bool
proc *process.Process
lock sync.RWMutex
}
)