I have a similar need. I'm using gRPC and some of my domain types are 
similar to the protobuffer messages, they pretty much have the same fields 
and types but the struct type is different. I haven't been able to convert 
them using normal means, is there any suggestion about how to go about it 
that is not manually mapping field by field?



On Tuesday, January 13, 2015 at 2:51:29 PM UTC-5, Rob 'Commander' Pike 
wrote:
>
> With that out of the way, here's an even simpler version. It depends on 
> the same thing under the covers.
>
> http://play.golang.org/p/d87s9RksWC
>
> a := aaa{3}
> b := bbb(a) 
> fmt.Println("ok", b)
>
> -rob
>
> On Wed, Jan 14, 2015 at 6:45 AM, Rob Pike <r...@golang.org <javascript:>> 
> wrote:
>
>> If the structs are exactly the same inside, go through an unnamed type:
>>
>> http://play.golang.org/p/c8mNH8_CED
>>
>> a := aaa{3} var x struct{ CCC int } = a var b bbb = b fmt.Println("ok", 
>> b) 
>>
>> You can assign a named type to an an unnamed type of the exact same 
>> structure.
>>
>> Whatever your larger intent, you don't want to do this. It's bad style 
>> and not general.
>>
>> -rob
>>
>>
>>
>

-- 
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.
For more options, visit https://groups.google.com/d/optout.

Reply via email to