DEV Community

Discussion on: The Problem with Interfaces, and how Go Fixed it

Collapse
 
dean profile image
dean • Edited

I re-read your question and realized that no one really answered it. I didn't want to get into the whole concept of packages in Go in the blog post so I didn't go into it. Basically, when referring to a type, variable, or anything, you refer to it through packagename.whatever. Our Edible interface could be referred to as mypackage.Edible, the Burger struct could be referred to as mypackage.Burger, although we can just refer to them as Edible and Burger because they are in our package.

Meanwhile, the Salad struct must be referred to as theirpackage.Salad because it is in a different package.

Also, in terms of type collisions with method names, all arguments and the return type must match the interface's in order for it to be considered "implemented".