env

package
v0.15.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 16, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ZETA_TERMINAL_PROMPT  K      = "ZETA_TERMINAL_PROMPT"
	ZETA_NO_SSH_AUTH_SOCK K      = "ZETA_NO_SSH_AUTH_SOCK"
	StandardSeparator     string = ";"
)

VALUE

Variables

View Source
var (
	Environ = sync.OnceValue(func() []string {
		cleanEnv := make([]string, 0, len(allowedEnv))
		for _, e := range allowedEnv {
			if v, ok := LookupEnv(e); ok {
				cleanEnv = append(cleanEnv, e+"="+v)
			}
		}
		slices.Sort(cleanEnv)
		return cleanEnv
	})
)

Functions

func GetBool

func GetBool(name string, fallback bool) (bool, error)

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

func GetDuration(name string, fallback time.Duration) (time.Duration, error)

GetDuration fetches and parses a duration typed environment variable

func GetInt

func GetInt(name string, fallback int) (int, error)

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

func GetString(name string, fallback string) string

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 InitializeEnv

func InitializeEnv() error

func LookupEnv

func LookupEnv(key string) (string, bool)

func SanitizerEnv

func SanitizerEnv(removeKey ...string) []string

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 DeriveSanitizer

func DeriveSanitizer(b 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) Find

func (k K) Find() string

func (K) SimpleAtob

func (k K) SimpleAtob(dv bool) bool

SimpleAtob Obtain the boolean variable from the environment variable, if it does not exist, return the default value

func (K) SimpleAtoi

func (k K) SimpleAtoi(dv int64) int64

func (K) StrSplit

func (k K) StrSplit(sep string) []string

find envkey split to array

func (K) Strings

func (k K) Strings() []string

find envkey Strings to array

func (K) With

func (k K) With(s string) string

func (K) WithBool

func (k K) WithBool(b bool) string

func (K) WithInt

func (k K) WithInt(i int64) string

func (K) WithPaths

func (k K) WithPaths(sv []string) string

func (K) Withs

func (k K) Withs(sv []string) string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL