Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Where exactly does the struct pair implement the Stringer interface? Is it when the String method was added to it? What if you have interfaces with similar names?


>Is it when the String method was added to it?

Yes, that is how you satisfy an interface in Go.

>What if you have interfaces with similar names?

The problem of interfaces with similar names is actually no different than the problems of, for example, packages or functions having similar names. It's down to you to avoid naming things in a confusing manner.


There is no "implements" in go. A type either provides the methods to satisfy an interface, or it doesn't. The name of the interface doesn't matter, and it can satisfy an many interfaces as it wants.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: