Search code examples
gopluginsshared-librariessearch-path

Where does the Go runtime look for plugins?


I want to use the Go plugin facility, and if I call plugin.Open("…") with an absolute path, this works fine. Still, the original docs give the example plugin.Open("plugin_name.so"), thus, it should also work with the simple filename.

However, the docs fail to say what is the search path for these plugins. Do the same rules apply as for any shared library? FWIW, copying my plugin to /usr/lib and calling ldconfig was not sufficient.


Solution

  • If an absolute path is not provided in the plugin path, it is treated as a relative path and as such is always resolved against the current, working directory. So if you pass "plugin_name.so", it must be in the working directory. Normally it is the same folder where the executable binary is, unless the binary was launched from another folder, or the working directory was changed after that.