Skip to content

Commit 9c99bbd

Browse files
Fix named slices
When a type is a slice of another type we should use the type name itself and not a slice of the elements of the slice. Fixes #243
1 parent af8b230 commit 9c99bbd

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

Diff for: inception/decoder_tpl.go

+11-3
Original file line numberDiff line numberDiff line change
@@ -353,10 +353,18 @@ var handleSliceTxt = `
353353
{{.Name}} = []*{{getType $ic .Name .Typ.Elem.Elem}}{}
354354
{{end}}
355355
{{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}}
358362
{{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}}
360368
{{end}}
361369
{{end}}
362370

0 commit comments

Comments
 (0)