devfeel / mapper

A simple and easy go tools for auto mapper map to struct, struct to map, struct to struct, slice to slice, map to slice, map to json.
MIT License
390 stars 34 forks source link

不支持 struct 中带有struct 以及struct slice #3

Closed kingreatwill closed 5 years ago

kingreatwill commented 5 years ago

func ExampleMap_2() {

type ItemStruct1 struct {
    ProductId int64
}
type ItemStruct2 struct {
    ProductId int64
}
type ProductBasic struct {
    ProductId    int64
    CategoryType int 
    ProductTitle string
    item         ItemStruct1
}
type ProductGetResponse struct {
    // ProductBasic;
    ProductId    int64
    CategoryType int
    ProductTitle string
    item         ItemStruct2
}
basic := &ProductBasic{
    ProductId:    10001,
    CategoryType: 1,
    ProductTitle: "fdsffdsf待",
    item:         ItemStruct1{ProductId: 20},
}
response := &ProductGetResponse{}
mapper.AutoMapper(basic, response)
fmt.Println(response)
// output:20

}

devfeel commented 5 years ago

It is now supported in version 0.6.4.