<p>With the introduction of the new <a href="https://golang.org/cmd/go/#hdr-Description_of_build_modes">build modes</a> shouldn't it be possible to create some kind of plugin architecture for go programs.</p>
<p>For example: One main binaries that scans a directory with contain multiple binaries that are loaded during run time and can be called during run time as long as they implement predefinded interfaces?</p>
<hr/>**评论:**<br/><br/>joeshaw: <pre><p>There's no mechanism yet to programmatically load shared objects at runtime. That's the purpose of the "plugin" build mode (see <a href="https://golang.org/s/execmodes">https://golang.org/s/execmodes</a>), but it wasn't done for Go 1.5.</p></pre>TheMerovius: <pre><p>Not really. You want both the main program and the plugins to share the same runtime and compiler-generated type info (for interfaces to work). Afaik that is not currently the case. So you would still need to treat the plugins as basically a separate process and wrap it to transfer type info and so on. And you can already do that now (just with separate processes).</p>
<p>I might be wrong, though.</p></pre>synalx: <pre><p>In theory, it's possible. In practice it'd probably be too clunky to use effectively.</p></pre>IntellectualReserve: <pre><p>I've thought about how cool this would be for zero downtime http servers. You could load new route handlers, and all of the current requests would finish executing under the old handlers while new requests would go through the newly loaded handlers. </p></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传