Documentation

Overview

    Package env provides helper functions for manipulating environment variables holding filepath lists.

    Example

      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!
      

      Index

      Examples

      Constants

      View Source
      const VarGopath = "GOPATH"

        VarGopath is the Go workspace path variable name.

        View Source
        const VarPath = "PATH"

          VarPath is the OS (shell) specific executable search path variable name.

          Variables

          This section is empty.

          Functions

          func Gopath

          func Gopath() pathlist.List

            Gopath gets the Go workspace path.

            func Path

            func Path() pathlist.List

              Path gets the OS (shell) specific executable search path.

              func SetGopath

              func SetGopath(l pathlist.List) error

                SetGopath sets the Go workspace path.

                func SetPath

                func SetPath(l pathlist.List) error

                  SetPath sets the OS (shell) specific executable search path.

                  func SetSlice

                  func SetSlice(env []string, key string, list pathlist.List) []string

                    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.

                    func Slice

                    func Slice(env []string, key string) pathlist.List

                      Slice gets the value for key as a pathlist.List from a slice of environment variables (as used with os.Environ and os/exec.Cmd.Env).

                      Types

                      This section is empty.

                      Source Files