-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathmain_test.go
636 lines (559 loc) · 17.3 KB
/
main_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
package main
import (
"bytes"
"regexp"
"testing"
"github.com/globusdigital/deep-copy/deepcopy"
"github.com/google/go-cmp/cmp"
)
func Test_run(t *testing.T) {
tests := []struct {
name string
types typesVal
path string
pointer bool
skips skipsVal
maxdepth int
buildTags []string
method string
want []byte
}{
{name: "foo", types: typesVal{"Foo"}, path: "./testdata", want: []byte(FooFile)},
{name: "foo - pointer", types: typesVal{"Foo"}, pointer: true, path: "./testdata", want: []byte(FooPointerFile)},
{name: "foo - pointer, skip slice", types: typesVal{"Foo"}, pointer: true, skips: skipsVal{{"Slice": struct{}{}}}, path: "./testdata", want: []byte(FooPointerSkipSliceFile)},
{name: "foo, skip map member", types: typesVal{"Foo"}, skips: skipsVal{{"Map[k]": struct{}{}}}, path: "./testdata", want: []byte(FooSkipMapFile)},
{name: "alpha - with DeepCopy method", types: typesVal{"Alpha"}, path: "./testdata", want: []byte(AlphaPointer)},
{name: "slicepointer, skip slice member", types: typesVal{"SlicePointer"}, skips: skipsVal{{"[i]": struct{}{}}}, path: "./testdata", want: []byte(SlicePointer)},
{name: "foo, alpha, skips", types: typesVal{"Foo", "Alpha"}, skips: skipsVal{{"Map[k]": struct{}{}, "ch": struct{}{}}, {"D": struct{}{}, "E": struct{}{}}}, path: "./testdata", want: []byte(FooAlphaSkips)},
{name: "foo, method=Clone", types: typesVal{"Foo"}, path: "./testdata", method: "Clone", want: []byte(FooCloneFile)},
{name: "issue 3, struct with slice of simple structs", types: typesVal{"I3WithSlice"}, pointer: true, path: "./testdata", want: []byte(Issue3SliceSimpleStruct)},
{name: "issue 3, struct with map of simple struct keys", types: typesVal{"I3WithMap"}, pointer: true, path: "./testdata", want: []byte(Issue3MapSimpleStructKey)},
{name: "issue 3, struct with map of simple struct values", types: typesVal{"I3WithMapVal"}, path: "./testdata", want: []byte(Issue3MapSimpleStructVal)},
{name: "issue 7, shadowed map vars", types: typesVal{"SomeStruct2"}, path: "./testdata", want: []byte(Issue7ShadowedMapVars)},
{name: "issue 7, shadowed map vars 2", types: typesVal{"SomeStruct", "SomeStruct2"}, path: "./testdata", want: []byte(Issue7ShadowedMapVars2)},
{name: "pointer that implements DeepCopy", types: typesVal{"SomeStruct"}, path: "./testdata/pointer_that_implements_deepcopy/somepkg", want: []byte(PointerThatImplementsDeepcopy)},
{name: "issue 10, slice with element that contains pointer and value", types: typesVal{"StructCH"}, path: "./testdata", want: []byte(Issue10StructCH)},
{name: "issue 12, nested slices", types: typesVal{"I12NestedSlices"}, path: "./testdata", want: []byte(Issue12NestedSlices)},
{name: "issue 12, map with slice value", types: typesVal{"I12StructWithMapOfSlices"}, path: "./testdata", want: []byte(Issue12MapWithSliceValues)},
{name: "issue 15, parent has child value, value receiver", types: typesVal{"ParentHasChildValue", "Child"}, path: "./testdata", want: []byte(I15ParentHasChildValueValueRecv)},
{name: "issue 15, parent has child pointer, value receiver", types: typesVal{"ParentHasChildPointer", "Child"}, path: "./testdata", want: []byte(I15ParentHasChildPointerValueRecv)},
{name: "issue 15, parent has child value, pointer receiver", pointer: true, types: typesVal{"ParentHasChildValue", "Child"}, path: "./testdata", want: []byte(I15ParentHasChildValuePointerRecv)},
{name: "issue 15, parent has child pointer, pointer receiver", pointer: true, types: typesVal{"ParentHasChildPointer", "Child"}, path: "./testdata", want: []byte(I15ParentHasChildPointerPointerRecv)},
{name: "issue 17, with maxdepth", types: typesVal{"Depth1"}, pointer: true, maxdepth: 2, path: "./testdata", want: []byte(Issue17MaxDepth)},
{name: "alias import", types: typesVal{"Data"}, path: "./testdata/import_alias", want: []byte(AliasImport)},
{name: "using build tags", types: typesVal{"Foo"}, path: "./testdata", buildTags: []string{"!myTag", "anotherOne"}, want: []byte(FooFileBuildTags)},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
method := "DeepCopy"
if tt.method != "" {
method = tt.method
}
g := deepcopy.NewGenerator(
deepcopy.IsPtrRecv(tt.pointer),
deepcopy.WithMethodName(method),
deepcopy.WithSkipLists(deepcopy.SkipLists(tt.skips)),
deepcopy.WithMaxDepth(tt.maxdepth),
deepcopy.WithBuildTags(tt.buildTags),
)
var buf bytes.Buffer
err := run(g, &buf, tt.path, tt.types)
if err != nil {
t.Fatal(err)
}
got := normalizeComment(buf.Bytes())
if diff := cmp.Diff(got, tt.want); diff != "" {
t.Errorf("generateFile() diff = %s", diff)
}
})
}
}
var re = regexp.MustCompile(`Code generated by deep-copy.*; DO NOT EDIT.`)
func normalizeComment(in []byte) []byte {
return re.ReplaceAll(bytes.TrimSpace(in), []byte("Code generated by deep-copy; DO NOT EDIT."))
}
const (
FooFile = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of Foo
func (o Foo) DeepCopy() Foo {
var cp Foo = o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
var cp_Map_v2 *Bar
if v2 != nil {
cp_Map_v2 = new(Bar)
*cp_Map_v2 = *v2
if v2.Slice != nil {
cp_Map_v2.Slice = make([]string, len(v2.Slice))
copy(cp_Map_v2.Slice, v2.Slice)
}
}
cp.Map[k2] = cp_Map_v2
}
}
if o.ch != nil {
cp.ch = make(chan float32, cap(o.ch))
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return cp
}`
FooPointerFile = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *Foo
func (o *Foo) DeepCopy() *Foo {
var cp Foo = *o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
var cp_Map_v2 *Bar
if v2 != nil {
cp_Map_v2 = new(Bar)
*cp_Map_v2 = *v2
if v2.Slice != nil {
cp_Map_v2.Slice = make([]string, len(v2.Slice))
copy(cp_Map_v2.Slice, v2.Slice)
}
}
cp.Map[k2] = cp_Map_v2
}
}
if o.ch != nil {
cp.ch = make(chan float32, cap(o.ch))
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return &cp
}`
FooPointerSkipSliceFile = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *Foo
func (o *Foo) DeepCopy() *Foo {
var cp Foo = *o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
var cp_Map_v2 *Bar
if v2 != nil {
cp_Map_v2 = new(Bar)
*cp_Map_v2 = *v2
}
cp.Map[k2] = cp_Map_v2
}
}
if o.ch != nil {
cp.ch = make(chan float32, cap(o.ch))
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return &cp
}`
FooSkipMapFile = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of Foo
func (o Foo) DeepCopy() Foo {
var cp Foo = o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
cp.Map[k2] = v2
}
}
if o.ch != nil {
cp.ch = make(chan float32, cap(o.ch))
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return cp
}`
AlphaPointer = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of Alpha
func (o Alpha) DeepCopy() Alpha {
var cp Alpha = o
if o.B != nil {
cp.B = o.B.DeepCopy()
}
cp.G = o.G.DeepCopy()
if o.D != nil {
retV := o.D.DeepCopy()
cp.D = &retV
}
{
retV := o.E.DeepCopy()
cp.E = *retV
}
return cp
}`
SlicePointer = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of SlicePointer
func (o SlicePointer) DeepCopy() SlicePointer {
var cp SlicePointer = o
if o != nil {
cp = make([]*int, len(o))
copy(cp, o)
}
return cp
}`
FooAlphaSkips = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of Foo
func (o Foo) DeepCopy() Foo {
var cp Foo = o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
cp.Map[k2] = v2
}
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return cp
}
// DeepCopy generates a deep copy of Alpha
func (o Alpha) DeepCopy() Alpha {
var cp Alpha = o
if o.B != nil {
cp.B = o.B.DeepCopy()
}
cp.G = o.G.DeepCopy()
return cp
}`
FooCloneFile = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// Clone generates a deep copy of Foo
func (o Foo) Clone() Foo {
var cp Foo = o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
var cp_Map_v2 *Bar
if v2 != nil {
cp_Map_v2 = new(Bar)
*cp_Map_v2 = *v2
if v2.Slice != nil {
cp_Map_v2.Slice = make([]string, len(v2.Slice))
copy(cp_Map_v2.Slice, v2.Slice)
}
}
cp.Map[k2] = cp_Map_v2
}
}
if o.ch != nil {
cp.ch = make(chan float32, cap(o.ch))
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return cp
}`
Issue3SliceSimpleStruct = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *I3WithSlice
func (o *I3WithSlice) DeepCopy() *I3WithSlice {
var cp I3WithSlice = *o
if o.a != nil {
cp.a = make([]I3SimpleStruct, len(o.a))
copy(cp.a, o.a)
}
return &cp
}`
Issue3MapSimpleStructKey = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *I3WithMap
func (o *I3WithMap) DeepCopy() *I3WithMap {
var cp I3WithMap = *o
if o.a != nil {
cp.a = make(map[I3SimpleStruct]string, len(o.a))
for k2, v2 := range o.a {
cp.a[k2] = v2
}
}
return &cp
}`
Issue3MapSimpleStructVal = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of I3WithMapVal
func (o I3WithMapVal) DeepCopy() I3WithMapVal {
var cp I3WithMapVal = o
if o.a != nil {
cp.a = make(map[string]I3SimpleStruct, len(o.a))
for k2, v2 := range o.a {
cp.a[k2] = v2
}
}
return cp
}`
Issue7ShadowedMapVars = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of SomeStruct2
func (o SomeStruct2) DeepCopy() SomeStruct2 {
var cp SomeStruct2 = o
if o.mapStruct != nil {
cp.mapStruct = make(map[string]SomeStruct, len(o.mapStruct))
for k2, v2 := range o.mapStruct {
var cp_mapStruct_v2 SomeStruct
if v2.mapSlice != nil {
cp_mapStruct_v2.mapSlice = make(map[string][]string, len(v2.mapSlice))
for k4, v4 := range v2.mapSlice {
var cp_mapStruct_v2_mapSlice_v4 []string
if v4 != nil {
cp_mapStruct_v2_mapSlice_v4 = make([]string, len(v4))
copy(cp_mapStruct_v2_mapSlice_v4, v4)
}
cp_mapStruct_v2.mapSlice[k4] = cp_mapStruct_v2_mapSlice_v4
}
}
cp.mapStruct[k2] = cp_mapStruct_v2
}
}
return cp
}`
Issue7ShadowedMapVars2 = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of SomeStruct
func (o SomeStruct) DeepCopy() SomeStruct {
var cp SomeStruct = o
if o.mapSlice != nil {
cp.mapSlice = make(map[string][]string, len(o.mapSlice))
for k2, v2 := range o.mapSlice {
var cp_mapSlice_v2 []string
if v2 != nil {
cp_mapSlice_v2 = make([]string, len(v2))
copy(cp_mapSlice_v2, v2)
}
cp.mapSlice[k2] = cp_mapSlice_v2
}
}
return cp
}
// DeepCopy generates a deep copy of SomeStruct2
func (o SomeStruct2) DeepCopy() SomeStruct2 {
var cp SomeStruct2 = o
if o.mapStruct != nil {
cp.mapStruct = make(map[string]SomeStruct, len(o.mapStruct))
for k2, v2 := range o.mapStruct {
var cp_mapStruct_v2 SomeStruct
cp_mapStruct_v2 = v2.DeepCopy()
cp.mapStruct[k2] = cp_mapStruct_v2
}
}
return cp
}`
Issue10StructCH = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of StructCH
func (o StructCH) DeepCopy() StructCH {
var cp StructCH = o
if o.Nested != nil {
cp.Nested = make([]StructNested, len(o.Nested))
copy(cp.Nested, o.Nested)
for i2 := range o.Nested {
if o.Nested[i2].B != nil {
cp.Nested[i2].B = new(int)
*cp.Nested[i2].B = *o.Nested[i2].B
}
}
}
return cp
}`
PointerThatImplementsDeepcopy = `// Code generated by deep-copy; DO NOT EDIT.
package somepkg
// DeepCopy generates a deep copy of SomeStruct
func (o SomeStruct) DeepCopy() SomeStruct {
var cp SomeStruct = o
if o.AnotherStruct != nil {
cp.AnotherStruct = o.AnotherStruct.DeepCopy()
}
return cp
}`
Issue12NestedSlices = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of I12NestedSlices
func (o I12NestedSlices) DeepCopy() I12NestedSlices {
var cp I12NestedSlices = o
if o.Slices != nil {
cp.Slices = make([][][]int, len(o.Slices))
copy(cp.Slices, o.Slices)
for i2 := range o.Slices {
if o.Slices[i2] != nil {
cp.Slices[i2] = make([][]int, len(o.Slices[i2]))
copy(cp.Slices[i2], o.Slices[i2])
for i3 := range o.Slices[i2] {
if o.Slices[i2][i3] != nil {
cp.Slices[i2][i3] = make([]int, len(o.Slices[i2][i3]))
copy(cp.Slices[i2][i3], o.Slices[i2][i3])
}
}
}
}
}
return cp
}`
Issue12MapWithSliceValues = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of I12StructWithMapOfSlices
func (o I12StructWithMapOfSlices) DeepCopy() I12StructWithMapOfSlices {
var cp I12StructWithMapOfSlices = o
if o.Sc1 != nil {
cp.Sc1 = make(map[string][]I12StructWithSlices, len(o.Sc1))
for k2, v2 := range o.Sc1 {
var cp_Sc1_v2 []I12StructWithSlices
if v2 != nil {
cp_Sc1_v2 = make([]I12StructWithSlices, len(v2))
copy(cp_Sc1_v2, v2)
for i3 := range v2 {
if v2[i3].Name != nil {
cp_Sc1_v2[i3].Name = make([]string, len(v2[i3].Name))
copy(cp_Sc1_v2[i3].Name, v2[i3].Name)
}
}
}
cp.Sc1[k2] = cp_Sc1_v2
}
}
return cp
}`
I15ParentHasChildValueValueRecv = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of ParentHasChildValue
func (o ParentHasChildValue) DeepCopy() ParentHasChildValue {
var cp ParentHasChildValue = o
cp.c = o.c.DeepCopy()
return cp
}
// DeepCopy generates a deep copy of Child
func (o Child) DeepCopy() Child {
var cp Child = o
return cp
}`
I15ParentHasChildPointerValueRecv = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of ParentHasChildPointer
func (o ParentHasChildPointer) DeepCopy() ParentHasChildPointer {
var cp ParentHasChildPointer = o
if o.c != nil {
retV := o.c.DeepCopy()
cp.c = &retV
}
return cp
}
// DeepCopy generates a deep copy of Child
func (o Child) DeepCopy() Child {
var cp Child = o
return cp
}`
I15ParentHasChildValuePointerRecv = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *ParentHasChildValue
func (o *ParentHasChildValue) DeepCopy() *ParentHasChildValue {
var cp ParentHasChildValue = *o
{
retV := o.c.DeepCopy()
cp.c = *retV
}
return &cp
}
// DeepCopy generates a deep copy of *Child
func (o *Child) DeepCopy() *Child {
var cp Child = *o
return &cp
}`
I15ParentHasChildPointerPointerRecv = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *ParentHasChildPointer
func (o *ParentHasChildPointer) DeepCopy() *ParentHasChildPointer {
var cp ParentHasChildPointer = *o
if o.c != nil {
cp.c = o.c.DeepCopy()
}
return &cp
}
// DeepCopy generates a deep copy of *Child
func (o *Child) DeepCopy() *Child {
var cp Child = *o
return &cp
}`
Issue17MaxDepth = `// Code generated by deep-copy; DO NOT EDIT.
package testdata
// DeepCopy generates a deep copy of *Depth1
func (o *Depth1) DeepCopy() *Depth1 {
var cp Depth1 = *o
if o.a1 != nil {
cp.a1 = new(Depth2)
*cp.a1 = *o.a1
}
if o.a2 != nil {
cp.a2 = new(Depth2)
*cp.a2 = *o.a2
}
return &cp
}`
AliasImport = `// Code generated by deep-copy; DO NOT EDIT.
package import_alias
import (
github_com_globusdigital_deep_copy_testdata_import_alias_another_item "github.com/globusdigital/deep-copy/testdata/import_alias/another/item"
"github.com/globusdigital/deep-copy/testdata/import_alias/item"
)
// DeepCopy generates a deep copy of Data
func (o Data) DeepCopy() Data {
var cp Data = o
if o.Items != nil {
cp.Items = make([]item.Item, len(o.Items))
copy(cp.Items, o.Items)
}
if o.AnotherItems != nil {
cp.AnotherItems = make([]github_com_globusdigital_deep_copy_testdata_import_alias_another_item.Item, len(o.AnotherItems))
copy(cp.AnotherItems, o.AnotherItems)
}
return cp
}`
FooFileBuildTags = `// Code generated by deep-copy; DO NOT EDIT.
//go:build !myTag
//go:build anotherOne
// +build !myTag
// +build anotherOne
package testdata
// DeepCopy generates a deep copy of Foo
//
func (o Foo) DeepCopy() Foo {
var cp Foo = o
if o.Map != nil {
cp.Map = make(map[string]*Bar, len(o.Map))
for k2, v2 := range o.Map {
var cp_Map_v2 *Bar
if v2 != nil {
cp_Map_v2 = new(Bar)
*cp_Map_v2 = *v2
if v2.Slice != nil {
cp_Map_v2.Slice = make([]string, len(v2.Slice))
copy(cp_Map_v2.Slice, v2.Slice)
}
}
cp.Map[k2] = cp_Map_v2
}
}
if o.ch != nil {
cp.ch = make(chan float32, cap(o.ch))
}
if o.baz.StringPointer != nil {
cp.baz.StringPointer = new(string)
*cp.baz.StringPointer = *o.baz.StringPointer
}
return cp
}`
)