Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( NullErrorHandler = func(error) {} StdoutErrorHandler = func(err error) { fmt.Fprintln(os.Stdout, err) } StderrErrorHandler = func(err error) { fmt.Fprintln(os.Stderr, err) } LogErrorHandler = func(err error) { log.Println(err) } )
Implementations of different error handlers.
var ErrorHandler = StderrErrorHandler
ErrorHandler defines a handler for error messages. By default, LogErrorHandler is set.
Functions ¶
func ParseFlags ¶
func ParseFlags()
ParseFlags tests if the print-flag was given at the program start and prints the registered environment fields with thier values to stdout using the specified format. Afterwards, the program exits with return code 2.
Types ¶
type BoolField ¶
type BoolField struct {
// contains filtered or unexported fields
}
BoolField implements a duration field.
func (*BoolField) DefaultValue ¶
DefaultValue returns the field's default value.
func (*BoolField) Description ¶
Description returns the field's description.
type BytesField ¶
type BytesField struct {
// contains filtered or unexported fields
}
BytesField implements a string field.
func Bytes ¶
func Bytes(name string, defaultValue []byte, opts ...Option) *BytesField
Bytes registers a field of the provided name.
func (*BytesField) DefaultValue ¶
func (bf *BytesField) DefaultValue() string
DefaultValue returns the field's default value.
func (*BytesField) Description ¶
func (bf *BytesField) Description() string
Description returns the field's description.
func (*BytesField) Get ¶
func (bf *BytesField) Get() []byte
Get returns the field value or the default value.
type DurationField ¶
type DurationField struct {
// contains filtered or unexported fields
}
DurationField implements a duration field.
func Duration ¶
func Duration(name string, defaultValue time.Duration, opts ...Option) *DurationField
Duration registers a field of the provided name.
func (*DurationField) DefaultValue ¶
func (df *DurationField) DefaultValue() string
DefaultValue returns the field's default value.
func (*DurationField) Description ¶
func (df *DurationField) Description() string
Description returns the field's description.
func (*DurationField) Get ¶
func (df *DurationField) Get() time.Duration
Get returns the field value or the default value.
func (*DurationField) Value ¶
func (df *DurationField) Value() string
Value returns the field's value.
type Field ¶
Field implements an environment configuration field.
func RegisterField ¶
RegisterField adds the provided `Field` to the global field-register.
type IntField ¶
type IntField struct {
// contains filtered or unexported fields
}
IntField implements a duration field.
func (*IntField) DefaultValue ¶
DefaultValue returns the field's default value.
func (*IntField) Description ¶
Description returns the field's description.
type IntsField ¶
type IntsField struct {
// contains filtered or unexported fields
}
IntsField implements a ints field.
func (*IntsField) DefaultValue ¶
DefaultValue returns the field's default value.
func (*IntsField) Description ¶
Description returns the field's description.
type Option ¶
type Option func(*options)
Option defines an Option that can modify the options struct.
func AllowedValues ¶
AllowedValues returns an Option that defines all allowed values for the environment field.
func Description ¶
Description returns an Option that sets the description of the environment field.
type StringField ¶
type StringField struct {
// contains filtered or unexported fields
}
StringField implements a string field.
func String ¶
func String(name, defaultValue string, opts ...Option) *StringField
String registers a field of the provided name.
func (*StringField) DefaultValue ¶
func (sf *StringField) DefaultValue() string
DefaultValue returns the field's default value.
func (*StringField) Description ¶
func (sf *StringField) Description() string
Description returns the field's description.
func (*StringField) Get ¶
func (sf *StringField) Get() string
Get returns the field value or the default value.
type StringsField ¶
type StringsField struct {
// contains filtered or unexported fields
}
StringsField implements a strings field.
func Strings ¶
func Strings(name string, defaultValue []string, opts ...Option) *StringsField
Strings registers a field of the provided name.
func (*StringsField) DefaultValue ¶
func (sf *StringsField) DefaultValue() string
DefaultValue returns the field's default value.
func (*StringsField) Description ¶
func (sf *StringsField) Description() string
Description returns the field's description.
func (*StringsField) Get ¶
func (sf *StringsField) Get() []string
Get returns the field value or the default value.
func (*StringsField) Value ¶
func (sf *StringsField) Value() string
Value returns the field's value.