Documentation ¶
Overview ¶
Package envutil provides utilities for working with environment variables.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Dedup ¶
Dedup returns a copy of env with any duplicates removed, in favor of later values. Items are expected to be on the normal environment "key=value" form.
Keys are interpreted as if on the given GOOS. (On Windows, key comparison is case-insensitive.)
func Match ¶
Match checks whether a "key=value" string matches key and, if so, returns the value.
On Windows, the key comparison is case-insensitive.
func SetDir ¶
SetDir sets cmd.Dir to dir, and also updates cmd.Env to ensure that PWD matches.
If dir is the empty string, SetDir clears cmd.Dir and sets PWD to the current working directory.
func SetEnv ¶
SetEnv sets cmd.Env to include the given key=value pairs, removing any duplicates for the key and leaving all other keys unchanged.
(Removing duplicates is not strictly necessary with modern versions of the Go standard library, but causes less confusion if cmd.Env is written to a log — as is sometimes done in packages within this module.)
Types ¶
This section is empty.