#Ad-hoc compile and send Go plugin over a network to be executed in a running Go app address space

9 messages · Page 1 of 1 (latest)

modern jewel
#

So the title is pretty much the summary I can squeeze in - I have to take a quite complex decision tree, generate some Go function that has certain signature, compile it as a plugin and then send the ".so" object over network and hot-plug it into a running application.

While compiling go code / sending over net seems doable with standard tools - I wonder how can I execute the plugin function without spawning a process / doing some IPC.

Maybe this is too esoteric 🙂

young dragon
#

go has a little-used plugin infrastructure

#

if you're on linux you can absolutely do it

#

but the short version is

  • compile the plugins as .so
  • load them via the network or filesystem
  • cast them to the proper types in the usual way f := v.(func(int) int)
  • use as normal
modern jewel
#

Correct, I am just curious - how do I load these plugins after the application is started.

young dragon
#

well, there's only one function in the package, so I'd use that one.

#

the actual management of it is up to you. probably you'll need to provide some kind of concurrency-safe lookup mechanism.

#

hmm, this is a somewhat interesting problem. i'm gonna mess around and see if I can come up with a decent API.