env

package
v0.0.0-...-4c191b4 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Expand

func Expand(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Expand expands the environment variables in the given string and returns the result.

Params:

  • content (string): The given string to expand.

Returns:

  • The expanded string. This expands against the os environemnt (os.ExpandEnv).

func Get

func Get(c cookoo.Context, params *cookoo.Params) (interface{}, cookoo.Interrupt)

Get gets one or more environment variables and puts them into the context.

Parameters passed in are of the form varname => defaultValue.

r.Route("foo", "example").Does(envvar.Get).Using("HOME").WithDefault(".")

As with all environment variables, the default value must be a string.

WARNING: Since parameters are a map, order of processing is not guaranteed. If order is important, you'll need to call this command multiple times.

For each parameter (`Using` clause), this command will look into the environment for a matching variable. If it finds one, it will add that variable to the context. If it does not find one, it will expand the default value (so you can set a default to something like "$HOST:$PORT") and also put the (unexpanded) default value back into the context in case any subsequent call to `os.Getenv` occurs.

func Set

func Set(c cookoo.Context, p *cookoo.Params) (interface{}, cookoo.Interrupt)

Set takes the given names and values and puts them into both the context and the environment.

Unlike Get, it does not try to retrieve the values from the environment first.

Values are passed through os.ExpandEnv()

There is no guarantee of insertion order. If multiple name/value pairs are given, they will be put into the context in whatever order they are retrieved from the underlying map.

Params:

accessed as map[string]string

Returns:

nothing, but inserts all name/value pairs into the context and the
environment.

Types

This section is empty.

Jump to

Keyboard shortcuts

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