Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Ensure ¶
Ensure adds custom error messagse to the error returned by LoadWithPrefix().
Normal usage looks like this:
err := configs.LoadWithPrefix(&cfg, "MYAPP") err = configs.Ensure(err, "MYAPP_PORT", cfg.Port > 0, "must be a positive integer") err = configs.Ensure(err, "MYAPP_ENV", isValid(cfg.ENV), "must be one of: %v", validEnvs)
If predicate is true, err is returned unchanged. If predicate is false and err is nil, a new error will be returned.
In all cases the returned error will "pretty print" your validation error alongside any errors generated by the LoadWithPrefix() call.
func LoadWithPrefix ¶
LoadWithPrefix loads the values of environment variables into a struct. It returns an error if any of the environment variable values don't match the type defined on the struct.
func LogWithPrefix ¶
func LogWithPrefix(container interface{}, prefix string)
LogWithPrefix prints all the environment variables and their values on container to stdout, excluding any which include the name "password" (for security)
func MustLoadWithPrefix ¶
func MustLoadWithPrefix(container interface{}, prefix string)
MustLoadWithPrefix loads the environment variables into a struct. It panics if any of the environment variables' values can't be coerced into the type defined on the struct.
Types ¶
This section is empty.