@@ -5,48 +5,48 @@ import (
55 "reflect"
66)
77
8- type fieldData struct {
8+ type FieldData struct {
99 Field reflect.StructField
1010 Value reflect.Value
1111 TagValue string
12- Parent * fieldData
12+ Parent * FieldData
1313}
1414
15- type fillerFunc func (field * fieldData )
15+ type FillerFunc func (field * FieldData )
1616
1717// Filler contains all the functions to fill any struct field with any type
1818// allowing to define function by Kind, Type of field name
1919type Filler struct {
20- FuncByName map [string ]fillerFunc
21- FuncByType map [TypeHash ]fillerFunc
22- FuncByKind map [reflect.Kind ]fillerFunc
20+ FuncByName map [string ]FillerFunc
21+ FuncByType map [TypeHash ]FillerFunc
22+ FuncByKind map [reflect.Kind ]FillerFunc
2323 Tag string
2424}
2525
2626// Fill apply all the functions contained on Filler, setting all the possible
2727// values
2828func (f * Filler ) Fill (variable interface {}) {
2929 fields := f .getFields (variable )
30- f .setDefaultValues (fields )
30+ f .SetDefaultValues (fields )
3131}
3232
33- func (f * Filler ) getFields (variable interface {}) []* fieldData {
33+ func (f * Filler ) getFields (variable interface {}) []* FieldData {
3434 valueObject := reflect .ValueOf (variable ).Elem ()
3535
36- return f .getFieldsFromValue (valueObject , nil )
36+ return f .GetFieldsFromValue (valueObject , nil )
3737}
3838
39- func (f * Filler ) getFieldsFromValue (valueObject reflect.Value , parent * fieldData ) []* fieldData {
39+ func (f * Filler ) GetFieldsFromValue (valueObject reflect.Value , parent * FieldData ) []* FieldData {
4040 typeObject := valueObject .Type ()
4141
4242 count := valueObject .NumField ()
43- var results []* fieldData
43+ var results []* FieldData
4444 for i := 0 ; i < count ; i ++ {
4545 value := valueObject .Field (i )
4646 field := typeObject .Field (i )
4747
4848 if value .CanSet () {
49- results = append (results , & fieldData {
49+ results = append (results , & FieldData {
5050 Value : value ,
5151 Field : field ,
5252 TagValue : field .Tag .Get (f .Tag ),
@@ -58,15 +58,15 @@ func (f *Filler) getFieldsFromValue(valueObject reflect.Value, parent *fieldData
5858 return results
5959}
6060
61- func (f * Filler ) setDefaultValues (fields []* fieldData ) {
61+ func (f * Filler ) SetDefaultValues (fields []* FieldData ) {
6262 for _ , field := range fields {
6363 if f .isEmpty (field ) {
64- f .setDefaultValue (field )
64+ f .SetDefaultValue (field )
6565 }
6666 }
6767}
6868
69- func (f * Filler ) isEmpty (field * fieldData ) bool {
69+ func (f * Filler ) isEmpty (field * FieldData ) bool {
7070 switch field .Value .Kind () {
7171 case reflect .Bool :
7272 if field .Value .Bool () != false {
@@ -97,8 +97,8 @@ func (f *Filler) isEmpty(field *fieldData) bool {
9797 return true
9898}
9999
100- func (f * Filler ) setDefaultValue (field * fieldData ) {
101- getters := []func (field * fieldData ) fillerFunc {
100+ func (f * Filler ) SetDefaultValue (field * FieldData ) {
101+ getters := []func (field * FieldData ) FillerFunc {
102102 f .getFunctionByName ,
103103 f .getFunctionByType ,
104104 f .getFunctionByKind ,
@@ -115,23 +115,23 @@ func (f *Filler) setDefaultValue(field *fieldData) {
115115 return
116116}
117117
118- func (f * Filler ) getFunctionByName (field * fieldData ) fillerFunc {
118+ func (f * Filler ) getFunctionByName (field * FieldData ) FillerFunc {
119119 if f , ok := f .FuncByName [field .Field .Name ]; ok == true {
120120 return f
121121 }
122122
123123 return nil
124124}
125125
126- func (f * Filler ) getFunctionByType (field * fieldData ) fillerFunc {
126+ func (f * Filler ) getFunctionByType (field * FieldData ) FillerFunc {
127127 if f , ok := f .FuncByType [GetTypeHash (field .Field .Type )]; ok == true {
128128 return f
129129 }
130130
131131 return nil
132132}
133133
134- func (f * Filler ) getFunctionByKind (field * fieldData ) fillerFunc {
134+ func (f * Filler ) getFunctionByKind (field * FieldData ) FillerFunc {
135135 if f , ok := f .FuncByKind [field .Field .Type .Kind ()]; ok == true {
136136 return f
137137 }
0 commit comments