<p>I know I am not supposed to think about virtual functions when programming in Go. :> However, recently I noticed that there is a "code reuse via dynamic dispatch" pattern lurking in some of my projects anyway, and so I took some time to extract it into a demo project to help myself re-execute the pattern should the need arise again. I also performed a simple benchmark with the demo to get some idea of the performance overhead of this pattern. I thought maybe I can share the demo project here:</p>
<p><a href="https://github.com/maverickwoo/go-vtable-demo" rel="nofollow">https://github.com/maverickwoo/go-vtable-demo</a></p>
<p>Cheers!</p>
<hr/>**评论:**<br/><br/>ar3s3ru: <pre><p>I don't get the meaning of this.<br/>
We already have dynamic dispatching in Go, through embedding and interface mechanisms.</p>
<p>Also, your code seems not to follow the best practices (a.k.a. "idiomatic Go"), so I'd suggest you to learn those!</p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传