Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrSourcerNil = errors.New("source cannot be nil") ErrNotPointer = errors.New("input must be a pointer") ErrNotStruct = errors.New("input must be a struct") ErrPrivateField = errors.New("cannot parse private fields") ErrUnknownOption = errors.New("unknown option") ErrMissingKey = errors.New("missing key") ErrRequiredAndDefault = errors.New("cannot set both `required` and `default`") ErrMissingRequired = errors.New("missing required value") ErrInvalidMapItem = errors.New("invalid map item") ErrPrefixNotStruct = errors.New("prefix is only valid on struct types") )
Functions ¶
func ProcessWith ¶
func ProcessWith(ctx context.Context, target interface{}, s Sourcer, mfn ...MutatorFunc) error
Types ¶
type Decoder ¶
Decoder is an interface that custom types/fields can implement to control how decoding takes place. For example:
type MyType string func (mt MyType) Decode(val string) error { return "CUSTOM-"+val }
type FieldOptions ¶
FieldOptions maintain flag options for a given field.
type MutatorFunc ¶
MutatorFunc is a function that mutates a given value before it is passed along for processing. This is useful if you want to mutate the environment variable value before it's converted to the proper type.
type Sourcer ¶
type Sourcer interface { // Source takes given key and returns the corresponding string value. // Returns true if found with the value. If a value is // not found, it returns the empty string and false. Source(key string) (string, bool) }
Sourcer is an interface that provides a lookup for a string-based key.
func NewEnvSourcer ¶
func NewEnvSourcer() Sourcer
func PrefixSourcer ¶
PrefixSourcer looks up environment configuration using the specified prefix. This is useful if you want all your variables to start with a particular prefix like "MY_APP_".
Click to show internal directories.
Click to hide internal directories.