Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
plugin: cannot load plugin when other dependent packages changed #20554
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
I see no way around this. Beyond the practical issue that using the dynamic loader to hot-swap code is extremely difficult, there are definitional issues. What if the init functions have changed between versions of a package? They can't be called again. What if a global variable already being used by running code changes type or is removed?
For your specific problem, consider introducing an interface type registered with a control package. When a new plugin is loaded, remove the implementation of the interface that comes from the old plugin, and add the implementation that comes from the new plugin. This lets you hot-swap running code (though you are slowly accumulating all previous versions into the process).