Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion automapper.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down
13 changes: 13 additions & 0 deletions automapper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down