Documentation ¶
Overview ¶
This library allow to define a default value to any struct, this is made thanks to struct tags.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetDefaults ¶
func SetDefaults(variable interface{})
Applies the default values to the struct object, the struct type must have the StructTag with name "default" and the directed value.
Usage
type ExampleBasic struct { Foo bool `default:"true"` Bar string `default:"33"` Qux int8 Dur time.Duration `default:"2m3s"` } foo := &ExampleBasic{} SetDefaults(foo)
Types ¶
type Filler ¶ added in v1.1.0
type Filler struct { FuncByName map[string]FillerFunc FuncByType map[TypeHash]FillerFunc FuncByKind map[reflect.Kind]FillerFunc Tag string }
Filler contains all the functions to fill any struct field with any type allowing to define function by Kind, Type of field name
func (*Filler) Fill ¶ added in v1.1.0
func (f *Filler) Fill(variable interface{})
Fill apply all the functions contained on Filler, setting all the possible values
func (*Filler) GetFieldsFromValue ¶ added in v1.2.0
func (*Filler) SetDefaultValue ¶ added in v1.2.0
func (*Filler) SetDefaultValues ¶ added in v1.2.0
type FillerFunc ¶ added in v1.2.0
type FillerFunc func(field *FieldData)
Click to show internal directories.
Click to hide internal directories.