Hypothetically, if there was a syntax in Go that did this, what would you 
do next ? In other words, what is the problem you are trying to solve that 
has lead you to needing this feature?

On Tuesday, 2 August 2016 18:18:05 UTC+10, Rayland wrote:
>
> I basically need something like this:
>
> var obj = &Person{Name: "John"} // I don't know what type obj will be 
> everytime
> var newObj interface{}
>
> initNewObj(obj) // now newObj is an empty object of type *Person
>
>
>
>
> On Tuesday, August 2, 2016 at 10:21:01 AM UTC+3, Dave Cheney wrote:
>>
>> TL;DR a shallow copy is easy, but it's almost never what you want.
>>
>> https://play.golang.org/p/wpWN3Znop8
>>
>> Needing to copy an arbitrary value is usually an anti pattern as values 
>> can contain references to other values, which contain references to other 
>> values, which contain references to other values, sometimes leading back to 
>> the previous values.
>>
>> On Tuesday, 2 August 2016 17:13:21 UTC+10, Rayland wrote:
>>>
>>> Let's say I have an object A of some type. Is there a way to create a 
>>> new object B with the same type as A without knowing the type of A in 
>>> advance?
>>>
>>

-- 
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