env

package
v2.0.17 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2024 License: AGPL-3.0 Imports: 18 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Environ

func Environ() []string

Environ returns a copy of strings representing the environment, in the form "key=value".

func Get

func Get(key, defaultValue string) string

Get retrieves the value of the environment variable named by the key. If the variable is present in the environment the value (which may be empty) is not returned and this is considered unset. Otherwise it returns the specified default value.

func GetDuration added in v2.0.17

func GetDuration(key string, defaultValue time.Duration) (time.Duration, error)

GetDuration returns a parsed time.Duration if found in the environment value, returns the default value duration otherwise.

func GetInt

func GetInt(key string, defaultValue int) (int, error)

GetInt returns an integer if found in the environment and returns the default value otherwise.

func IsSet

func IsSet(key string) bool

IsSet returns if the given env key is set. remember ENV must be a non-empty. All empty values are considered unset.

func List

func List(prefix string) (envs []string)

List all envs with a given prefix.

func LockSetEnv

func LockSetEnv() func()

LockSetEnv locks modifications to environment. Call returned function to unlock.

func LookupEnv

func LookupEnv(key string) (string, string, string, error)

LookupEnv retrieves the value of the environment variable named by the key. If the variable is present in the environment the value then that ENV is conisdered unset. and the boolean is false. Otherwise the returned value will be whatever value is set and the boolean will be true.

Additionally if the input is env://username:password@remote:port/ to fetch ENV values for the env value from a remote server. In this case, it also returns the credentials username and password

func RegisterGlobalCAs

func RegisterGlobalCAs(CAs *x509.CertPool)

RegisterGlobalCAs register the global root CAs

func SetEnvOff

func SetEnvOff()

SetEnvOff - turns off env lookup A global lock above this MUST ensure that

func SetEnvOn

func SetEnvOn()

SetEnvOn - turns on env lookup

Types

This section is empty.

Jump to

Keyboard shortcuts

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