Documentation ¶
Overview ¶
Package env provides a few helpers to load in environment variables with defaults
Index ¶
- type Loader
- func (l *Loader) Bool(fld *bool, env string)
- func (l *Loader) ChangeDefault(env, def string)
- func (l *Loader) Err() error
- func (l *Loader) Int(fld *int, env string)
- func (l *Loader) SecretFromFile(fld *secret.String, env string)
- func (l *Loader) String(fld *string, env string)
- func (l *Loader) VarsUsed() Vars
- type Var
- type Vars
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Loader ¶
type Loader struct {
// contains filtered or unexported fields
}
func (*Loader) Bool ¶
Bool inspects the system env var given by env. If it is present it will use the truthy or falsy strings as per ParseBool to set the contents of fld. If the parse fails the content of fld is left unaltered and the loader multi error added to.
func (*Loader) ChangeDefault ¶
func (*Loader) Int ¶
Int inspects the system env var given by env. If it is present it will parse the value as an int as per Atoi to set the contents of fld. If the parse fails the content of fld is left unaltered and the loader multi error added to.
func (*Loader) SecretFromFile ¶
SecretFromFile loads in the content of the file given in the env var. A slight potential trap is that the default value provided would be the content of the file and not the file path. If the env var is not set or is set but is empty then the default value is left unaltered and the loader multi error added to.