The "VTable pattern" in Go

agolangf · · 415 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>I know I am not supposed to think about virtual functions when programming in Go. :&gt; However, recently I noticed that there is a &#34;code reuse via dynamic dispatch&#34; 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&#39;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. &#34;idiomatic Go&#34;), so I&#39;d suggest you to learn those!</p></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

415 次点击  
加入收藏 微博
0 回复
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传