diff --git a/automapper.go b/automapper.go index 1ef7f4e..05796ee 100644 --- a/automapper.go +++ b/automapper.go @@ -81,7 +81,7 @@ func mapValues(sourceVal, destVal reflect.Value, loose bool) { } else if destType.Kind() == reflect.Slice { mapSlice(sourceVal, destVal, loose) } else { - panic("Currently not supported") + destVal.Set(sourceVal.Convert(destType)) } } diff --git a/automapper_test.go b/automapper_test.go index bd8b93e..70c9bd9 100644 --- a/automapper_test.go +++ b/automapper_test.go @@ -256,6 +256,19 @@ func TestWithLooseOption(t *testing.T) { assert.Equal(t, dest.Bar, 0) } +func TestNamedType(t *testing.T) { + type SourceType string + type DestType string + source := struct { + Foo SourceType + }{"abc"} + dest := struct { + Foo DestType + }{} + Map(&source, &dest) + assert.Equal(t, string(source.Foo), string(dest.Foo)) +} + type SourceParent struct { Children []SourceTypeA }