Letting "D" stand for "Database":
func (d D) GetDatabase() etc
func (d *D) Connect() etc
Note that some of these are D, others are *D with a star.
The thing is that *D gets the methods that are defined by D, but not
vice versa. (http://golang.org/ref/spec#Method_sets says that "The
method set of the corresponding pointer type *T is the set of all
methods declared with receiver *T or T (that is, it also contains the
method set of T)")
Thus, *D has a Connect method AND a GetDatabase method (ignoring the
others for now). D without a * only has a GetDatabase method, not a
The Connector interface includes the Connect method. Thus, *D
satisfies this interface, but D does not.
Your original NewDatabase function returns a D, not a *D, which the
compiler correctly rejects, because a D is not a Connector.
The best fix is to make all of your receivers *D, not a mix of D and
*D. Even after that, I'd still return a *D instead of a D.
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 firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.