Let's consider the following program
type Fruit interface {
    Color() string
}
type Apple struct {
    color string
}
func (x *Apple) Color() string {
    return x.color
}
func (x *Apple) Compare(y Fruit) bool {
    _, ok := y.(*Apple)
    if ok {
        ok = y.Color() == x.Color()
    }
    return ok
}
func main() {
    a := Apple{"red"}
    b := Apple{"green"}
    a.Compare(&b)
}
Now, note the last line that says a.Compare(&b). Here I am passing a pointer to Apple. This works correctly, but note that my Compare
function does NOT accept the pointer (y Fruit).
Now if I change the last line to say a.Compare(b) then it gives me the following error:
cannot use b (type Apple) as type Fruit in argument to a.Compare:
    Apple does not implement Fruit (Color method has pointer receiver)
What is [go]ing on here?
 
     
    