Documentation ¶
Overview ¶
Package env provides a standardised interface to environment variables, including parsing, validation and export checks.
Index ¶
- Variables
- func BindAddr(name, usage string) *string
- func Bool(name string, usage string) *bool
- func DialAddr(name, usage string) *string
- func Duration(name string, usage string) *time.Duration
- func Float32(name string, usage string) *float32
- func Float64(name string, usage string) *float64
- func Int(name string, usage string) *int
- func Int64(name string, usage string) *int64
- func Parse() error
- func Path(name, usage string) *string
- func String(name, usage string) *string
- func StringRequired(name, usage string) *string
- func URL(name, usage string) *url.URL
- func Visit(fn func(*Var))
- type Errors
- type Getter
- type Value
- type Var
- type VarSet
- func (v *VarSet) BindAddr(name, usage string) *string
- func (v *VarSet) Bool(name string, usage string) *bool
- func (v *VarSet) DialAddr(name, usage string) *string
- func (v *VarSet) Duration(name string, usage string) *time.Duration
- func (v *VarSet) Float32(name string, usage string) *float32
- func (v *VarSet) Float64(name string, usage string) *float64
- func (v *VarSet) Int(name string, usage string) *int
- func (v *VarSet) Int64(name string, usage string) *int64
- func (v *VarSet) Name() string
- func (v *VarSet) Parse(g Getter) error
- func (v *VarSet) Path(name, usage string) *string
- func (v *VarSet) Prefix() string
- func (v *VarSet) String(name string, usage string) *string
- func (v *VarSet) StringRequired(name string, usage string) *string
- func (v *VarSet) URL(name, usage string) *url.URL
- func (v *VarSet) Var(value Value, name, usage string)
- func (v *VarSet) Visit(fn func(v *Var))
Constants ¶
This section is empty.
Variables ¶
CmdName is used to create the default variable set name.
var CmdVar = NewVarSet(CmdName())
CmdVar is the default variable set used for command-line based applications. The name of the variable set (and hence all variable prefixes) is given by CmdName.
Functions ¶
func BindAddr ¶
BindAddr defines a string variable with specified name, usage string validated as a bind address (host:port). The return value is the address of a string variable that stores the value of the variable.
func Bool ¶
Bool defines a bool variable with specified name and usage string. The return value is the address of a bool variable that stores the value of the variable.
func DialAddr ¶
DialAddr defines a string variable with specified name, usage string validated as a dial address (host:port). The return value is the address of a string variable that stores the value of the variable.
func Duration ¶
Duration defines a time.Duration variable with specified name, usage string and validation checks. The return value is the address of a time.Duration variable that stores the value of the variable.
func Float32 ¶ added in v0.6.0
Float32 defines an float32 variable with specified name and usage string. The return value is the address of an int variable that stores the value of the variable.
func Float64 ¶ added in v0.6.0
Float64 defines an float64 variable with specified name and usage string. The return value is the address of an int variable that stores the value of the variable.
func Int ¶
Int defines an int variable with specified name and usage string. The return value is the address of an int variable that stores the value of the variable.
func Int64 ¶ added in v0.2.0
Int64 defines an int64 variable with specified name and usage string. The return value is the address of an int variable that stores the value of the variable.
func Path ¶
Path defines a string variable with specified name, usage string validated as a local path. The return value is the address of a string variable that stores the value of the variable.
func String ¶
String defines a string variable with specified name, usage string and validation checks. The return value is the address of a string variable that stores the value of the variable.
func StringRequired ¶
StringRequired defines a required string variable with specified name and usage string.. The return value is the address of a string variable that stores the value of the variable.
Types ¶
type Value ¶
type Value interface { // String is a string representation of the stored value. String() string // Set assigns a new value to a stored value from a string // representation. Set(string) error }
Value is the interface to the dynamic value stored in Var.
type VarSet ¶
type VarSet struct {
// contains filtered or unexported fields
}
VarSet contains a set of variables.
func NewVarSet ¶
NewVarSet creates a new variable set with given name.
If name is non-empty, then all variables will have a strings.ToUpper(name)+"_" prefix.
func (*VarSet) BindAddr ¶
BindAddr defines a string variable with specified name, usage string validated as a bind address (host:port). The return value is the address of a string variable that stores the value of the variable.
func (*VarSet) Bool ¶
Bool defines a bool variable with specified name, usage string and validation checks. The return value is the address of a bool variable that stores the value of the variable.
func (*VarSet) DialAddr ¶
DialAddr defines a string variable with specified name, usage string validated as a dial address (host:port). The return value is the address of a string variable that stores the value of the variable.
func (*VarSet) Duration ¶
Duration defines a time.Duration variable with specified name, usage string and validation checks. The return value is the address of a time.Duration variable that stores the value of the variable.
func (*VarSet) Float32 ¶ added in v0.6.0
Float32 defines an float32 variable with specified name, usage string and validation checks. The return value is the address of an float32 variable that stores the value of the variable.
func (*VarSet) Float64 ¶ added in v0.6.0
Float64 defines an float64 variable with specified name, usage string and validation checks. The return value is the address of an float64 variable that stores the value of the variable.
func (*VarSet) Int ¶
Int defines an int variable with specified name, usage string and validation checks. The return value is the address of an int variable that stores the value of the variable.
func (*VarSet) Int64 ¶ added in v0.2.0
Int64 defines an int64 variable with specified name, usage string and validation checks. The return value is the address of an int variable that stores the value of the variable.
func (*VarSet) Path ¶
Path defines a string variable with specified name, usage string validated as a local path. The return value is the address of a string variable that stores the value of the variable.
func (*VarSet) String ¶
String defines a string variable with specified name, usage string and validation checks. The return value is the address of a string variable that stores the value of the variable.
func (*VarSet) StringRequired ¶
StringRequired defines a required string variable with specified name and usage string. The return value is the address of a string variable that stores the value of the variable.
func (*VarSet) URL ¶ added in v0.3.0
URL defines a string variable with specified name, usage string validated as a URL. The return value is the address of a URL variable that stores the value of the variable.