Documentation ¶
Overview ¶
Package environ is a system to implement the similar functionality as environment lists found in all Unix-based OS'. Basically, all the functions found at "man 3 setenv" from a Unix prompt. With some additions to support Go's basic types.
Index ¶
- Constants
- type Env
- func (e *Env) Contains(name string) bool
- func (e *Env) Free()
- func (e *Env) Get(name string) string
- func (e *Env) GetBool(name string) bool
- func (e *Env) GetFloat(name string) float64
- func (e *Env) GetInt(name string) int
- func (e *Env) GetTime(name string) time.Time
- func (e *Env) Index(name string) int
- func (e *Env) Print()
- func (e *Env) Put(name, value string)
- func (e *Env) Set(name string, v interface{}) error
- func (e *Env) Unset(name string)
Constants ¶
const Version = "0.2.3"
Version is the version of this package
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Env ¶
type Env []string
Env is an environment list with name=value values.
func (*Env) Free ¶
func (e *Env) Free()
Free returns this Env e back into the pool for further use. It's recommended to use this function when we are done using e.
func (*Env) GetBool ¶
GetBool returns the bool value matching name in Env e, or false if not found or the value is not a boolean.
func (*Env) GetFloat ¶
GetFloat returns the float value matching name in Env e, or 0 if not found or the value is not a float.
func (*Env) GetInt ¶
GetInt returns the int value matching name in Env e, or 0 if not found or the value is not an int.
func (*Env) GetTime ¶
GetTime returns the time.Time value matching name in Env e, or time.Time{} if not found or the value is not a time.Time. The parsing is done using format: "2006-01-02 15:04:05.999999999 -0700 MST", which is a variation on time.RFC3339Nano. The returned value should be checked with time.IsZero()
func (*Env) Index ¶
Index returns the index of the first instance of name found in Env e, or -1 otherwise.
func (*Env) Put ¶
Put inserts name=value into Env e if a value matching name is not found. Otherwise it replaces the current name=value with the new value.