Interface imposes a set of restrictions on a object, which makes it useful 
in the first place.
If it doesn't, then you won't be able to replace the type of the object 
assigned to the interface.
Say, if you change the type of fooModel to something with different fields, 
you would have to change all the code referencing 'Id' directly or 
indirectly though interface.

On Wednesday, February 8, 2017 at 9:57:02 AM UTC+8, 高橋誠二 wrote:
>
> https://play.golang.org/p/KEGDmlLEZZ
>
> like this, can't use var model ModelObject as FooModel struct.
> I'd like to use model as FooModel variable, after inserting &FooModel{Id: 
> 1} to model.
> Why this happen?
>

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

Reply via email to