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 any)
SetDefaults 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 ¶
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 ¶
Fill apply all the functions contained on Filler, setting all the possible values
func (*Filler) GetFieldsFromValue ¶
GetFieldsFromValue ...
func (*Filler) SetDefaultValue ¶
SetDefaultValue ...
func (*Filler) SetDefaultValues ¶
SetDefaultValues ...
type FillerFunc ¶
type FillerFunc func(field *FieldData)
Click to show internal directories.
Click to hide internal directories.