How to implement two-way module communication in Go?

At our work we have a project that has modules, specific structs with a lot of available methods, it was created a few years back with the idea of creating even more modules and enabling easy communication between them, so the other developers chose NATS. The problem with NATS is, that it creates too much boilerplate code to call the needed function. Is there any way, to setup a two-way communication between two module objects so I could call one from the other and vice versa.
So:

func (*mod1) doSomething() {
    mod2.write()
}

func (*mod2) doSomethingToo() {
    mod1.read()
}

Is there a way to not use a websocket and communicate while inside of a program? Or is that not doable?
Thanks for any kind of help.

so your problem is cyclic import ?
there is a lot of blogs about how to deal with it.

You have you considered:

  • RCP (e.g via unix socket)
  • make some broker module
  • function pointers

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.