@@ -11,11 +11,13 @@ var (
11
11
errType = reflect .TypeOf ((* error )(nil )).Elem ()
12
12
)
13
13
14
+ // structCopier data structure of copier that copies from a `struct`
14
15
type structCopier struct {
15
16
ctx * Context
16
17
fieldCopiers []copier
17
18
}
18
19
20
+ // Copy implementation of Copy function for struct copier
19
21
func (c * structCopier ) Copy (dst , src reflect.Value ) error {
20
22
for _ , cp := range c .fieldCopiers {
21
23
if err := cp .Copy (dst , src ); err != nil {
@@ -201,44 +203,54 @@ func (c *structCopier) createCustomCopier(df, sf *reflect.StructField, cp copier
201
203
}
202
204
}
203
205
206
+ // structFieldDirectCopier data structure of copier that copies from
207
+ // a src field to a dst field directly
204
208
type structFieldDirectCopier struct {
205
209
dstField int
206
210
srcField int
207
211
}
208
212
213
+ // Copy implementation of Copy function for struct field copier direct
209
214
func (c * structFieldDirectCopier ) Copy (dst , src reflect.Value ) error {
210
215
dst .Field (c .dstField ).Set (src .Field (c .srcField ))
211
216
return nil
212
217
}
213
218
219
+ // structFieldConvCopier data structure of copier that copies from
220
+ // a src field to a dst field with type conversion
214
221
type structFieldConvCopier struct {
215
222
dstField int
216
223
srcField int
217
224
}
218
225
226
+ // Copy implementation of Copy function for struct field copier with type conversion
219
227
func (c * structFieldConvCopier ) Copy (dst , src reflect.Value ) error {
220
228
dstVal := dst .Field (c .dstField )
221
229
dstVal .Set (src .Field (c .srcField ).Convert (dstVal .Type ()))
222
230
return nil
223
231
}
224
232
233
+ // structFieldCopier wrapping copier for copying struct field
225
234
type structFieldCopier struct {
226
235
copier copier
227
236
dstField int
228
237
srcField int
229
238
}
230
239
240
+ // Copy implementation of Copy function for struct field copier
231
241
func (c * structFieldCopier ) Copy (dst , src reflect.Value ) error {
232
242
return c .copier .Copy (dst .Field (c .dstField ), src .Field (c .srcField ))
233
243
}
234
244
245
+ // structFieldMethodCopier data structure of copier that copies between `fields` and `methods`
235
246
type structFieldMethodCopier struct {
236
247
dstMethod int
237
248
dstMethodUnexported bool
238
249
srcField int
239
250
srcFieldUnexported bool
240
251
}
241
252
253
+ // Copy implementation of Copy function for struct field copier between `fields` and `methods`
242
254
func (c * structFieldMethodCopier ) Copy (dst , src reflect.Value ) error {
243
255
src = src .Field (c .srcField )
244
256
if c .srcFieldUnexported {
@@ -263,6 +275,7 @@ func (c *structFieldMethodCopier) Copy(dst, src reflect.Value) error {
263
275
return err
264
276
}
265
277
278
+ // structUnexportedFieldCopier data structure of copier that copies between unexported fields of struct
266
279
type structUnexportedFieldCopier struct {
267
280
copier copier
268
281
dstField int
@@ -271,6 +284,7 @@ type structUnexportedFieldCopier struct {
271
284
srcFieldUnexported bool
272
285
}
273
286
287
+ // Copy implementation of Copy function for struct unexported field copier
274
288
func (c * structUnexportedFieldCopier ) Copy (dst , src reflect.Value ) error {
275
289
src = src .Field (c .srcField )
276
290
if c .srcFieldUnexported {
0 commit comments