On Mon, Jun 27, 2016 at 4:16 PM David Koblas <kob...@gmail.com> wrote:

        type BaseAppController struct {
                *Application
                IGet
                IList
        }

The above means that every instance of BaseAppController satisfies both the
IGet and IList interfaces and that is known statically at compile time. I
don't understand why the code tests for that at run time. However, beware
that even though the interface is implemented by embedding a field of an
interface type, without setting that field to something actually handling
the method call you will get the panic(s) as you described.

"Subclasses" and parent/child type relations make little sense in Go
because composition is not inheritance. Yes, the methods of embedded fields
are merged to the method set of the embedding struct, but there the story
ends. Method set per se does not handle any actual method calls. There must
be always a real instance of a specific type that has the method. Note:
typed nil is a real instance of a type that can handle method calls, as
long as it does not try to dereference its receiver. But the zero value of
an embedded interface is not a real instance of any specific type.

-- 

-j

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