<p>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?</p>
<hr/>**评论:**<br/><br/>Sythe2o0: <pre><p>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. </p></pre>kostix: <pre><p>Please read this go-to article — <a href="https://research.swtch.com/interfaces" rel="nofollow">"Go Data Structures: Interfaces"</a> by Russ Cox.</p>
<p>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.</p></pre>paul2048: <pre><p>Cause it's a pointer?</p></pre>nemith: <pre><p>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.</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传