I've got a common project and small projects which act such as connectors in the common project.
I want to create a common project such that when a new connector is developed I don’t have to modify code in the common project. Is it possible to dynamically load the structures in Go, only knowing the path (by putting this path in a file in common project and at runtime load that struct) of the struct and its folders?
connector1
  connector1.go
  /util
  /domain
connectorN
  connectorN.go 
  /domain
commonProject
   main.go
   config.ini
Structure config.ini
Conector
name = connector1
path = ..../connector1/connector1.go
Conector
name = connectorN
path = ..../connectorN/connectorN.go
I know that this is possible to do this in Java with code like this, but I am trying to do this in Go. Any ideas?
Class.forName(String) 
or
ClassLoader.loadClass(String):
                I can see two ways to achieve what you describe, but keep in mind, as @icza pointed out, that go produces static binaries, so you can't load external libraries dynamically.
You can, however:
cgo to interface with C code, and load external libraries that
way.net/rpc package to have several binaries communicate
with each other, and load those on demand.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With