fix: support pointers to structs

This commit is contained in:
Peter 2023-01-30 18:14:53 +01:00
parent 73e9aafbfd
commit b59dd4d9aa
No known key found for this signature in database
2 changed files with 15 additions and 0 deletions

View file

@ -30,6 +30,7 @@ func (g *Gapr) Map(input any) (any, error) {
if t.Kind() == reflect.Pointer { if t.Kind() == reflect.Pointer {
t = t.Elem() t = t.Elem()
v = v.Elem()
} }
if !canMap(t) { if !canMap(t) {

View file

@ -30,6 +30,20 @@ func TestGapr_Map(t *testing.T) {
want: nil, want: nil,
wantErr: false, wantErr: false,
}, },
{
name: "Test simple struct pointer",
args: args{
input: &struct {
GivenName string
Surname string
}{
GivenName: "Ted",
Surname: "Tester",
},
},
want: nil,
wantErr: false,
},
{ {
name: "Test nested struct", name: "Test nested struct",
args: args{ args: args{