fix: support pointers to structs
This commit is contained in:
parent
73e9aafbfd
commit
b59dd4d9aa
2 changed files with 15 additions and 0 deletions
1
gapr.go
1
gapr.go
|
@ -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) {
|
||||||
|
|
14
gapr_test.go
14
gapr_test.go
|
@ -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{
|
||||||
|
|
Loading…
Reference in a new issue