This is totally different from java. I've read many articles, but seems like none of them dealing with the design purpose. Is there a TL;DR version of why is this?
评论:
Sythe2o0:
kostix:Where did you get the impression that an interface was an int? As a datatype, an interface is a collection of functions. In implementation, it's a pointer to a type and a value.
paul2048:Please read this go-to article — "Go Data Structures: Interfaces" by Russ Cox.
Note that it in the up-to-date "reference" implementation of Go (there are many in fact) "short" values (those which are less-than-or-equal to the size of the platform's pointer) are no longer cached in the interface values but this is an implementation detail you should safely ignore.
nemith:Cause it's a pointer?
At some point all values in a computer is just a number. In this case it would probably be a pointer to a memory location.
