英文:
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?
答案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
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论