One binary or many binaries


(Ronaldo) #1

Hi all,

I’m just starting my journey to Golang (or GoLand, :wink: ) and I would like the to hear from more experienced guys about how to proceed.

The thing is, I have five applications programmed in C. I would like to port those application to Go, but I have some issues with flash (HD) space.

My question is … should I make five Go applications and run them as five separate OS processes? that way each Go binary will have its own “whole Go underlying machine”. Or should I make just one Go application and make them all concurrent inside Go so that all-in-one Go application will end up consuming less flash memory since the “whole Go underlying machine” will be shared?

Thanks in advance.

[]s
Ronaldo


(Johan Dahl) #2

Are these five programs related? Or do they do totally different things?


(Norbert Melzer) #3

If the size of the executable matters, stick to size optimized C with dynamically linked shared libraries.

Also don’t forget to use strip.


(Ronaldo) #4

Well, today, in C, they are kind related, not completely … so that’s why they are five separate programs, but my question was more directed to the issue I have with my limited flash memory size.


(Johan Dahl) #5

Hi. You could of course do a command with several subcommands like git. git add, git commit and so on.


(Norbert Melzer) #6

Or use hard-/soft-links and dispatch over os.Args[0]


(Ronaldo) #7

Actually I think I was not clear on what I had in mind and after some days of research I think I reached a conclusion.

Please, just tell me if the following make sense:

Every Go application has a “runtime code” that ends up included in the final binary. So that counts for the ended size of this binary. If I have five Go binaries, all of them will count five times for the space they consume on my flash (Hard Disk). So if I only think in terms of flash consumption, I’ll better stick to only one binary with five features. Mathematically it would go like this:

Let’s imagine that each feature takes 1MByte and that the Go runtime code takes 2M, so:

Five binaries would take: (2MB+1MB)5 = 15MB
One binary with five features: 2MB + (1MB
5) = 7MB

Does it make sense to you?

Thanks


(Johan Dahl) #8

Hi again. Yes it makes sense.