envutil

package
v0.29.0 Latest Latest
Warning

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

Go to latest
Published: May 2, 2023 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendToPathList

func AppendToPathList(list string, value ...string) string

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

func Copy(dst []string, src []string) ([]string, error)

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

func GetEnvWithPathSubstring(env []string, key string, substring string) string

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

func Getenv(env []string, key string) string

Like os.Getenv but uses the specified environment instead of the current process environment.

func LookupEnv

func LookupEnv(env []string, key string) (string, bool)

Like os.LookupEnv but uses the specified environment instead of the current process environment.

func QuotedCommandWithEnv added in v0.13.0

func QuotedCommandWithEnv(args []string, env []string) string

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.

func QuotedEnv added in v0.13.0

func QuotedEnv(env []string) []string

func Setenv

func Setenv(env []string, key, value string) ([]string, error)

Like os.Setenv but uses the specified environment instead of the current process environment.

func ToMap

func ToMap(env []string) map[string]string

ToMap converts the specified strings representing an environment in the form "key=value" to a map.

Types

This section is empty.

Jump to

Keyboard shortcuts

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