From b59dd4d9aa14a93ee69b6d0d0b897dd60e59138c Mon Sep 17 00:00:00 2001 From: Peter Kurfer Date: Mon, 30 Jan 2023 18:14:53 +0100 Subject: [PATCH] fix: support pointers to structs --- gapr.go | 1 + gapr_test.go | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/gapr.go b/gapr.go index 550810c..e68e52e 100644 --- a/gapr.go +++ b/gapr.go @@ -30,6 +30,7 @@ func (g *Gapr) Map(input any) (any, error) { if t.Kind() == reflect.Pointer { t = t.Elem() + v = v.Elem() } if !canMap(t) { diff --git a/gapr_test.go b/gapr_test.go index c81c9e4..623eeab 100644 --- a/gapr_test.go +++ b/gapr_test.go @@ -30,6 +30,20 @@ func TestGapr_Map(t *testing.T) { want: nil, 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", args: args{