Package env provides helper functions for manipulating environment variables holding filepath lists.
This example demonstrates setting PATH and GOPATH, both for the current process (SetPath) and a child process (SetSlice). It first creates a new Go workspace for building a Hello World executable, adding the workspace to GOPATH when invoking the go tool. Then it invokes the executable built, adding the workspace bin directory to PATH.
Output: Hello World!
const VarGopath = "GOPATH"
VarGopath is the Go workspace path variable name.
const VarPath = "PATH"
VarPath is the OS (shell) specific executable search path variable name.
SetPath sets the OS (shell) specific executable search path.
SetSlice takes a slice of environment variables (as used with os.Environ and os/exec.Cmd.Env), and returns a copy of env with key set to list.