Thanh Pham / Wed 27 Oct 2021
Summary.An illustration of what and how interface works in Go. 
intertypefun[0]itabinterfacetype information_type information of the target typefun[0]!=0 means the type implements the interfaceitabTableitabThe itabTable is built at runtimeand will be updated whenever there's atype/interface conversion check.Go runtimeIf 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?intertypefun[0]itabinterfacetypetyppkgpathmhdrtype of the interfacepackage pathlist of methodskind...kind can be:basic: string, int, float,....or slice, map, func, chan,...structinterface_typestructtypetyppkgpathfieldstype of the structpackage pathlist of fieldsDesigned by Thanh PhamInterface_typedataefacetabdataifacearraytype...structtypeinterfacetype......_type list:empty interfaceinterface with methodskind..._typePtr to real dataIt's just a set of method signatures.Mostly used as a contract between two or more componentsof 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 intfunc (n Number) String() string { return strconv.Itoa(int(n))}This is how it is definedThis is how a type/struct implements it
Next In
Interface{} Explained

Interface values are stored as eface & iface during runtime. Go keeps track of struct & interface mapping in an internal list called itabTable. This list is built both at compile time and at runtime and will be used for checking if a struct implements an interface.