Hacker News new | ask | show | jobs
by jules 5086 days ago
How is that even possible? Surely there must be a type tag associated with each object if you can dispatch on it, just like in other languages.
2 comments

A variable of an interface type is a pair consisting of a type descriptor and a concrete value. It is only when a concrete value of a statically known type is passed to something expecting an interface type that such a type tagged value is constructed.
For interface values there is a type associated with each value.

For normal values you don't need it, because Go is statically typed. The compiler knows where the method is.