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 
sturct{Name string}, type B struct{Age int}, a,b :=A{"xxx"},B{10} called 
c:= merge(a,b), c is interface{}, and 

import "github.com/google/go-querystring/query",

v, _ := query.Values(opt)
fmt.Print(v.Encode()) // will output: "name=xxx&age=10"


在 2019年8月24日星期六 UTC+8下午1:29:03,Jan Mercl写道:
>
> On Sat, Aug 24, 2019 at 5:25 AM Lee Rick <blade...@gmail.com <javascript:>> 
> 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 struct{Name string, Address string} 
> > d3 := merge(b,c) //d3 like struct{Age int, Address string} 
> > 
> > 
> > how to realize merge function? anyone can give me a demo 
>
> Is this the XY problem? What is the task/goal? 
>

-- 
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 the web visit 
https://groups.google.com/d/msgid/golang-nuts/0decb22b-4b7b-4d6d-bd38-3b768998d367%40googlegroups.com.

Reply via email to