Documentation ¶
Index ¶
- func AppendToPathList(list string, value ...string) string
- func Copy(dst []string, src []string) ([]string, error)
- func GetEnvWithPathSubstring(env []string, key string, substring string) string
- func Getenv(env []string, key string) string
- func LookupEnv(env []string, key string) (string, bool)
- func QuotedCommandWithEnv(args []string, env []string) string
- func QuotedEnv(env []string) []string
- func Setenv(env []string, key, value string) ([]string, error)
- func ToMap(env []string) map[string]string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AppendToPathList ¶
AppendToPathList appends a string to another string containing a list of paths, separated by os.PathListSeparator (like the PATH and LD_LIBRARY_PATH environment variables). It doesn't add duplicates and removes any empty strings from the list.
func Copy ¶ added in v0.13.0
Copy copies all environment variables from src to dst. When an environment variable is already set in dst, the value in dst is overwritten.
func GetEnvWithPathSubstring ¶ added in v0.15.0
GetEnvWithPathSubstring retrieves the value of the environment variable named by the key in env. It returns the value, which will be empty if the variable is not present or if the last element of the path does not contain the given substring.
func Getenv ¶
Like os.Getenv but uses the specified environment instead of the current process environment.
func LookupEnv ¶
Like os.LookupEnv but uses the specified environment instead of the current process environment.
func QuotedCommandWithEnv ¶ added in v0.13.0
QuotedCommandWithEnv returns a string which can be executed in a shell to run the specified command with the specified environment variables. Useful for debug output to be able to run commands manually.
Note: When the result is printed, make sure that env doesn't contain arbitrary environment variables from the host to avoid leaking secrets in the log output.
Types ¶
This section is empty.