Documentation
¶
Overview ¶
Package env contains abstractions to work with environment variables, such as Variable and Environment. It also includes functions for better integration with the built-in os package.
Index ¶
Constants ¶
const ( Go111Module = "GO111MODULE" GoArch = "GOARCH" GoDebug = "GODEBUG" GoGC = "GOGC" GoMaxProcs = "GOMAXPROCS" GoOS = "GOOS" GoPath = "GOPATH" GoRace = "GORACE" GoRoot = "GOROOT" GoTraceback = "GOTRACEBACK" )
Environment variables relate to the built-in runtime package. See https://pkg.go.dev/runtime/#hdr-Environment_Variables.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Environment ¶
type Environment []Variable
Environment represents a set of environment variables.
func From ¶
func From(environ []string) Environment
From converts an environment in the form "key=value" into Environment. It skips invalid entries silently.
See the example.
func (Environment) Environ ¶
func (env Environment) Environ() []string
Environ returns a copy of strings representing the environment, in the form "key=value".
func (Environment) Lookup ¶
func (env Environment) Lookup(key string) (Variable, bool)
Lookup retrieves the value of the environment variable named by the key. If the variable is present in the environment, the value (which may be empty) is returned, and the boolean is true. Otherwise, the returned value will be empty, and the boolean will be false.
type Variable ¶
type Variable struct {
// contains filtered or unexported fields
}
Variable represents an environment variable.
func New ¶
New returns a new Variable on top of the passed key/value pair. It returns error if something went wrong.