Re: [go-nuts] how to merge different struct to one struct

2019-08-24 Thread jake6502
On Saturday, August 24, 2019 at 3:39:27 AM UTC-4, Lee Rick wrote: > > think that there are two struct, they have different fields, hope that > there has a function merge(a,b interface{}) interface{}, input param are > any two struct, they may have same-type, or have different-type. output >

Re: [go-nuts] how to merge different struct to one struct

2019-08-24 Thread Lee Rick
think that there are two struct, they have different fields, hope that there has a function merge(a,b interface{}) interface{}, input param are any two struct, they may have same-type, or have different-type. output param is a struct that composed the two input struct, example type A

Re: [go-nuts] how to merge different struct to one struct

2019-08-24 Thread Lee Rick
think that there are two struct, they have different fields, hope that there has a function merge(a,b interface{}) interface{}, input param are any two struct, they may have same-type, or have different-type. output param is a struct that composed the two input struct, example type A

Re: [go-nuts] how to merge different struct to one struct

2019-08-24 Thread Lee Rick
think that there are two struct, they have different fields, hope that there has a function merge(a,b interface{}) interface{}, input param are any two struct, they may have same-type, or have different-type. output param is a struct that composed the two input struct, example type A

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Jan Mercl
On Sat, Aug 24, 2019 at 5:25 AM Lee Rick wrote: > > i want to do > type A struct{ Name string} > type B struct{Age int} > type C struct{Address string} > > a, b, c := A{}, B{},C{} > have a function > d1 := merge(a,b) //d1 like struct{Name string, Age int} > d2 := merge(a,c) //d2 like

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Kurtis Rader
On Fri, Aug 23, 2019 at 10:11 PM Lee Rick wrote: > it's not my need, hope other methods > Then you need to explain why that answer is not satisfactory and otherwise better explain your requirements. In your hypothetical example the objects such as `d1` would not be usable except via reflection

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread burak serdar
On Fri, Aug 23, 2019 at 11:11 PM Lee Rick wrote: > > it's not my need, hope other methods What is your need? What are the types of the variables d1, d2, d3 in your example? > > 在 2019年8月24日星期六 UTC+8上午11:43:32,burak serdar写道: >> >> On Fri, Aug 23, 2019 at 9:25 PM Lee Rick wrote: >> > >> > i

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread Lee Rick
it's not my need, hope other methods 在 2019年8月24日星期六 UTC+8上午11:43:32,burak serdar写道: > > On Fri, Aug 23, 2019 at 9:25 PM Lee Rick > > wrote: > > > > i want to do > > type A struct{ Name string} > > type B struct{Age int} > > type C struct{Address string} > > > > a, b, c := A{}, B{},C{} >

Re: [go-nuts] how to merge different struct to one struct

2019-08-23 Thread burak serdar
On Fri, Aug 23, 2019 at 9:25 PM Lee Rick wrote: > > i want to do > type A struct{ Name string} > type B struct{Age int} > type C struct{Address string} > > a, b, c := A{}, B{},C{} > have a function > d1 := merge(a,b) //d1 like struct{Name string, Age int} > d2 := merge(a,c) //d2 like

[go-nuts] how to merge different struct to one struct

2019-08-23 Thread Lee Rick
i want to do type A struct{ Name string} type B struct{Age int} type C struct{Address string} a, b, c := A{}, B{},C{} have a function d1 := merge(a,b) //d1 like struct{Name string, Age int} d2 := merge(a,c) //d2 like struct{Name string, Address string} d3 := merge(b,c) //d3 like struct{Age