File tree 3 files changed +27
-3
lines changed
3 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -353,10 +353,18 @@ var handleSliceTxt = `
353
353
{{.Name}} = []*{{getType $ic .Name .Typ.Elem.Elem}}{}
354
354
{{end}}
355
355
{{else}}
356
- {{if eq .IsPtr true}}
357
- {{.Name}} = &[]{{getType $ic .Name .Typ.Elem}}{}
356
+ {{if eq .Typ.Name ""}}
357
+ {{if eq .IsPtr true}}
358
+ {{.Name}} = &[]{{getType $ic .Name .Typ.Elem}}{}
359
+ {{else}}
360
+ {{.Name}} = []{{getType $ic .Name .Typ.Elem}}{}
361
+ {{end}}
358
362
{{else}}
359
- {{.Name}} = []{{getType $ic .Name .Typ.Elem}}{}
363
+ {{if eq .IsPtr true}}
364
+ {{.Name}} = &{{getType $ic .Name .Typ}}{}
365
+ {{else}}
366
+ {{.Name}} = {{getType $ic .Name .Typ}}{}
367
+ {{end}}
360
368
{{end}}
361
369
{{end}}
362
370
Original file line number Diff line number Diff line change @@ -2305,3 +2305,14 @@ type XDominantField struct {
2305
2305
Name * int `json",omitempty"`
2306
2306
A * struct { X int } `json:"Name,omitempty"`
2307
2307
}
2308
+
2309
+ type NamedSlice []IntType
2310
+
2311
+ // ffjson: skip
2312
+ type TContainsNamedSlice struct {
2313
+ Slice * NamedSlice `json:"ns"`
2314
+ }
2315
+
2316
+ type XContainsNamedSlice struct {
2317
+ Slice * NamedSlice `json:"ns"`
2318
+ }
Original file line number Diff line number Diff line change @@ -860,3 +860,8 @@ func TestDominantField(t *testing.T) {
860
860
i := 43
861
861
testType (t , & TDominantField {Y : & i }, & XDominantField {Y : & i })
862
862
}
863
+
864
+ func TestNamedSlice (t * testing.T ) {
865
+ ns := NamedSlice {1 , 2 , 3 }
866
+ testType (t , & TContainsNamedSlice {Slice : & ns }, & XContainsNamedSlice {Slice : & ns })
867
+ }
You can’t perform that action at this time.
0 commit comments