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

2019-08-24 Thread Jacques Supcik
I'm glad I could help. Cheers, -- Jacques -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on t

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

2019-08-24 Thread Lee Rick
i read your code, and try to write my code, package main import ( "fmt" "reflect" ) type A struct{ Name string } type B struct{ Age int } type C struct{ Address string } func Merge(a interface{}, b interface{})( d interface{}) { aType := reflect.TypeOf(a) if aType.Kind() != reflect.Struct { pan

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

2019-08-24 Thread Jacques Supcik
As suggested by Kurtis Rader, I would use "reflection" for this. Here is a simple example (not fully tested, probably not safe, not production ready... so just for demonstration purpose) : https://play.golang.org/p/sAyBajxsTAN -- Jacques -- You received this message because you are subscribed