Golang插件热重载

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

Golang plugin hot reload

问题

我正在尝试在Go语言中重新加载一个插件,我正在使用Go 1.8版本。我尝试重新打开插件,但没有成功(Open函数用于打开一个Go插件。如果已经打开了一个路径,那么会返回现有的*Plugin对象。它可以安全地被多个goroutine并发使用-Go插件打开文档)。我想知道是否有一种方法可以在不重新运行服务器的情况下重新加载插件?

https://golang.org/pkg/plugin/

英文:

i'm trying to reload a plugin in Golang, i'm using Go 1.8. I try to open again the plugin but that didn't work(Open opens a Go plugin. If a path has already been opened, then the existing *Plugin is returned. It is safe for concurrent use by multiple goroutines. - Go Plugin open documentation). I want to know is any way to the reload without rerun the server?

https://golang.org/pkg/plugin/

答案1

得分: 3

据我所知,这是不可能的,因为Go语言无法卸载共享库。当在插件中创建了一些对象,并且这些对象被程序引用时,无法进行垃圾回收。可以参考这个问题:https://github.com/golang/go/issues/11100

英文:

As far as I know, It's impossible since go can't unload shared library. When created some objects in the plugin, and it's referenced from program, it can't do garbage collect. See this issue: https://github.com/golang/go/issues/11100

huangapple
  • 本文由 发表于 2017年6月29日 23:43:00
  • 转载请务必保留本文链接:https://go.coder-hub.com/44829665.html
匿名

发表评论

匿名网友

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

确定