elemToStruct to convert the different structs for assignment.
(fromElem, toElem reflect.Value)
| 95 | |
| 96 | // elemToStruct to convert the different structs for assignment. |
| 97 | func (dm *mapperObject) elemToStruct(fromElem, toElem reflect.Value) { |
| 98 | for i := 0; i < fromElem.NumField(); i++ { |
| 99 | fromFieldInfo := fromElem.Field(i) |
| 100 | fieldName := dm.getFieldName(fromElem, i) |
| 101 | if fieldName == IgnoreTagValue { |
| 102 | continue |
| 103 | } |
| 104 | if fieldName == CompositeFieldTagValue && |
| 105 | fromFieldInfo.Kind() == reflect.Struct { |
| 106 | //If composite fields are identified, further decomposition and judgment will be taken. |
| 107 | fromElem := fromFieldInfo |
| 108 | for i := 0; i < fromElem.NumField(); i++ { |
| 109 | fromFieldInfo := fromElem.Field(i) |
| 110 | fieldName := dm.getFieldName(fromElem, i) |
| 111 | if fieldName == IgnoreTagValue { |
| 112 | continue |
| 113 | } |
| 114 | err := dm.convertstructfieldInternal(fieldName, fromFieldInfo, toElem) |
| 115 | if err != nil { |
| 116 | fmt.Println("auto mapper failed", fromFieldInfo, "error", err.Error()) |
| 117 | } |
| 118 | } |
| 119 | } else { |
| 120 | err := dm.convertstructfieldInternal(fieldName, fromFieldInfo, toElem) |
| 121 | if err != nil { |
| 122 | fmt.Println("auto mapper failed", fromFieldInfo, "error", err.Error()) |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | } |
| 127 | |
| 128 | // convertstructfieldInternal to convert the fields of different structs for assignment. |
| 129 | func (dm *mapperObject) convertstructfieldInternal(fieldName string, fromFieldInfo, toElem reflect.Value) error { |
no test coverage detected