Documentation
¶
Overview ¶
Package xii contains helpers for 12 Factor.
Index ¶
- Constants
- func AsBool(key string, opts BoolOpts) (bool, error)
- func AsInt(key string, opts IntOpts) (int, error)
- func AsString(key string, opts StringOpts) (string, error)
- func GetBool(opts BoolOpts, keys ...string) (keyFound string, val bool, err error)
- func GetInt(opts IntOpts, keys ...string) (keyFound string, val int, err error)
- func GetString(opts StringOpts, keys ...string) (keyFound string, val string, err error)
- func SearchEnv(keys ...string) (key, val string, err error)
- type BoolOpts
- type IntOpts
- type StringOpts
Constants ¶
const ( ExtraSpaces = constError("must not contain leading or trailing spaces") InvalidBoolean = constError("must be either true or false") InvalidInteger = constError("must be a valid integer") IsBlank = constError("must not be blank") NotExported = constError("must be exported") )
Errors used by the package.
Variables ¶
This section is empty.
Functions ¶
func AsBool ¶
AsBool retrieves a boolean value from the environment. Returns an error if the value is missing or invalid.
func AsInt ¶
AsInt is retrieves an integer value from the environment. Returns an error if the value is missing or invalid.
func AsString ¶
func AsString(key string, opts StringOpts) (string, error)
AsString retrieves a string from the environment. Returns an error if the string is not set.
func GetBool ¶ added in v0.3.0
GetBool searches the environment for a list of keys. Returns the matching key's name and value. Returns an error if the key is not set or the value is invalid.
func GetInt ¶ added in v0.3.0
GetInt searches the environment for a list of keys. Returns the matching key's name and value. Returns an error if the key is not set or the value is invalid.
Types ¶
type BoolOpts ¶
type BoolOpts struct {
Required bool
DefaultKey string
DefaultValue bool
Help string // short help message if required and not found
}
BoolOpts specifies if a value is required or has a default value.