在golang中进行进程内动态插件的一种方法

huangapple go评论67阅读模式
英文:

One way to do in-process dynamic plugin in golang

问题

最近我正在尝试在Go语言中构建一个动态插件框架,我知道plugin构建模式尚未实现。

所以我考虑将Go插件构建为C风格的共享对象,然后主程序使用C.dlopen加载插件。

复杂的数据结构可以通过JSON编码的字符串传递。

这种方法可行吗?或者会有什么可预见的缺点?

提前感谢。

英文:

recently I'm trying to build a dynamic plugin framework in golang, I know the plugin buildmode hasn't been implemented yet.

So I'm thinking about building go plugin into c-style shared objects and the main program loading plugins using C.dlopen.

Complex data struct can be passed by json-encoded string.

Is this means doable? Or is there any foreseeable disadvantage could be caused?

Thanks in advance.

答案1

得分: 0

这种方法不是进行动态插件加载/重新加载的可行方式。
详细信息请参考这里:https://github.com/golang/go/issues/11100

即使在golang 1.8中的插件功能也不支持重新加载。

英文:

This method is not a possible way to do the dynamic plugin loading/reloading.
The detail lies here: https://github.com/golang/go/issues/11100

Even the plugin feature in golang 1.8 doesn't support reloading.

huangapple
  • 本文由 发表于 2016年12月8日 17:21:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/41035798.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定