Viacheslav,

Your best bet here in my opinion is to have an intermediate object that 
contains type information which you Unmarshal into first to get the 
concrete type.  Then, you have a switch to Unmarshal the remainder of the 
object into the real deal.  We did a similar mechanic to this on Docker 
Machine at one point where the various Drivers would contain a string 
indicating which type they "actually" are.

Nathan

On Monday, August 1, 2016 at 10:07:07 AM UTC-7, Viacheslav Biriukov wrote:
>
> Hi, 
>
> I want to marshal/unmarshal object for saving in key/value storage. 
> The question is: if I got this object using function, that accepts 
> interface type, lets say for example: base.Pricer. And there are more than 
> one type struct that satisfy this interface. I know while marshaling what 
> type this object have (using reflection), and theoretically can save this 
> type in storage. But when I try to load this object – I want to get exactly 
> that type what was before serialization. But I don't know how to do this 
> and is this is a good pattern?
>
> Thank you.
>

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