Summary. An illustration of what and how interface works in Go.
inter type fun[0] itab interfacetype information _type information of the target type fun[0]!=0 means the type implements the interface itabTable itab The itabTable is built at runtime and will be updated whenever there's a type/interface conversion check. Go runtime If it walks like a duck and it quacks like a duck, then it must be a duck! If there is no "implements" keywords, how does Go runtime check if a struct implements an interface? inter type fun[0] itab interfacetype typ pkgpath mhdr type of the interface package path list of methods kind ... kind can be: basic: string, int, float,.... or slice, map, func, chan,... struct interface _type structtype typ pkgpath fields type of the struct package path list of fields Designed by Thanh Pham Interface _type data eface tab data iface arraytype ... structtype interfacetype ... ... _type list: empty interface interface with methods kind ... _type Ptr to real data It's just a set of method signatures. Mostly used as a contract between two or more components of an application. You don't need to mention that you "implements" it in your code, Go will do it for you! It's a duck typing... Interface is great! but what is it, really? Uhm.. ....ah... type Stringer interface { String() string } type Number int func (n Number) String() string { return strconv.Itoa(int(n)) } This is how it is defined This is how a type/struct implements it