20. THE COMPILER IS COMPUTING A TABLE
FOR BINARY AND A TABLE FOR STRINGER
BINARY
[Type metadata]
Get() uint64
String() string
STRINGER
String() string
21. AT RUN TIME, THE
VARIABLE IS ALLOCATED
b := Binary(200)
200
Binary
22. NEXT, THE INTERFACE RUN TIME
COMPUTES AN INTERFACE TABLE (ITABLE)
b := Binary(200)
200
Binary
s := fmt.Stringer(b)
fmt.Stringer itable(Stringer, Binary)
...
itable
type(Binary)
(*Binary).String
type
fun[0]
tab
data
23. THE INTERFACE TYPE IS ALWAYS STRINGER
INTERFACES ARE NOT DYNAMICALLY TYPED
24. WITH THE EMPTY INTERFACE, WE CAN
OPTIMIZE THE MEMORY BY DO NOT CREATE A
NEW ITABLE
b := Binary(200)
200
Binary
any := (interface{})(b)
interface{}
type(Binary)type
data