Documentation
¶
Overview ¶
Package default allows users to initialize structs with default values as defined in struct tags. The default values are parsed from the struct tag string in the same way that environment variables from the confire env package are parsed.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var SetDefaults func(spec interface{}) error = Process
SetDefaults is an alias of Process
Functions ¶
func MustProcess ¶
func MustProcess(spec interface{})
MustProcess is the same as Process but panics if an error occurs
func Process ¶
func Process(spec interface{}) (err error)
Process a struct to add the defaults from the default struct tag, parsing the struct tag string into the correct type using the same methodology as processing environment variables. Most types are parsed using the strconv package (time.Duration is handled specially). If the type implements Decoder, Setter, TextUnmarshaler, or BinaryUnmarshaler, then those decoders are used to parse the default value.
Types ¶
This section is empty.