Documentation
¶
Index ¶
- Constants
- Variables
- func DelayInitializeEnv() error
- func GetBool(name string, fallback bool) (bool, error)
- func GetDuration(name string, fallback time.Duration) (time.Duration, error)
- func GetInt(name string, fallback int) (int, error)
- func GetString(name string, fallback string) string
- func LookupPager(name string) (string, error)
- func SanitizeEnv(keys ...string) []string
- type Broker
- type Builder
- type K
- func (k K) Find() string
- func (k K) SimpleAtob(dv bool) bool
- func (k K) SimpleAtoi(dv int64) int64
- func (k K) StrSplit(sep string) []string
- func (k K) Strings() []string
- func (k K) With(s string) string
- func (k K) WithBool(b bool) string
- func (k K) WithInt(i int64) string
- func (k K) WithPaths(sv []string) string
- func (k K) Withs(sv []string) string
Constants ¶
const ( ZETA_TERMINAL_PROMPT K = "ZETA_TERMINAL_PROMPT" ZETA_NO_SSH_AUTH_SOCK K = "ZETA_NO_SSH_AUTH_SOCK" StandardSeparator string = ";" )
VALUE
Variables ¶
var ( Environ = sync.OnceValue(func() []string { originEnv := os.Environ() sanitizedEnv := make([]string, 0, len(originEnv)) for _, e := range originEnv { k, _, ok := strings.Cut(e, "=") if !ok || !allowedEnv[k] { continue } sanitizedEnv = append(sanitizedEnv, e) } slices.Sort(sanitizedEnv) return sanitizedEnv }) )
Functions ¶
func DelayInitializeEnv ¶ added in v0.20.0
func DelayInitializeEnv() error
func GetBool ¶
GetBool fetches and parses a boolean typed environment variable
If the variable is empty, returns `fallback` and no error. If there is an error, returns `fallback` and the error.
func GetDuration ¶
GetDuration fetches and parses a duration typed environment variable
func GetInt ¶
GetInt fetches and parses an integer typed environment variable
If the variable is empty, returns `fallback` and no error. If there is an error, returns `fallback` and the error.
func GetString ¶
GetString fetches a given name from the environment and falls back to a default value if the name is not available. The value is stripped of leading and trailing whitespace.
func LookupPager ¶ added in v0.20.0
func SanitizeEnv ¶ added in v0.20.0
Types ¶
type Broker ¶
type Broker interface {
ExpandEnv(s string) string
LookupEnv(key string) (string, bool)
Getenv(string) string
Setenv(key, value string) error
Unsetenv(key string) error
Environ() []string
Clearenv()
}
var (
SystemBroker Broker = &broker{}
)
func NewSanitizer ¶
func NewSanitizer() Broker
type Builder ¶
type Builder interface {
Environ() []string
}
func NewBuilder ¶
func NewBuilder() Builder
type K ¶
type K string
func (K) SimpleAtob ¶
SimpleAtob Obtain the boolean variable from the environment variable, if it does not exist, return the default value