The "VTable pattern" in Go

agolangf · 2018-03-12 13:30:13 · 541 次点击    
这是一个分享于 2018-03-12 13:30:13 的资源,其中的信息可能已经有所发展或是发生改变。

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:

https://github.com/maverickwoo/go-vtable-demo

Cheers!


评论:

ar3s3ru:

I don't get the meaning of this.
We already have dynamic dispatching in Go, through embedding and interface mechanisms.

Also, your code seems not to follow the best practices (a.k.a. "idiomatic Go"), so I'd suggest you to learn those!


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

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