How to make use of Loadable modules in Go?

Hello Team,
This is my second week in go and have been working in php, python nodejs. Its really interesting to learn golang. The performance benefit from golang is outstanding compared to other technologies.

Coming to my point, I am working on a POC about building http server using echo. There other libraries as well such as Gin and Mux but I prefer Echo.

Now in any of these libraries, the basic idea of route is common. We prepare a route name, pattern and there is a handler function attached to it.

In my requirement, there are going to be 200 to 500 routes, they will have roughly 600+ handler functions. If I build this as a single application, it will become a super heavy application in terms of size, also it will be time consuming task to run go build.

So If i want to keep handler functions in all together separate build and import it in my main.go file in runtime, is it possible to do that?

Is it possible to create a separate executable of group of handler functions and call those executable if route is matched?

Apologies if the question has been repeated.

Thanks

I don’t have an answer to your question. However,

I don’t think this will be the case. I would expect a build time in seconds and a total application size that’s a lot smaller than the sum total of a lot of plugins. You can still split your server into lots of source files, use init functions to have handlers register themselves at load time and, if compilation time does become an issue, split it into multiple packages. Going for plugins from the start seems like over engineering to me.

Right now my Hello World executable application with one handler is consuming 7MB. Imagine an application having 500+ routes and their handler functions. How can I create multiple executable? (example each executable for each handler function)

Application will not grow per route added. Please read https://golang.org/doc/faq#Why_is_my_trivial_program_such_a_large_binary
and
https://science.raphael.poss.name/go-executable-size-visualization-with-d3.html

If you create multiple executables you will end up with heavier applications after all (in regard to the total size not architecture).

2 Likes

Better I have started with golang plugins.