How to reduce application exe size

How to reduce application exe size.

May I make my exe in small size by introducing concept like runtime loading code in golang

I think you can remove debug information from an application when building with -ldflags, if you want to do this :grinning:
for example:

-ldflags: Linker flags can be used to strip debug information and unused code.
go build -ldflags "-s -w" -o yourapp
-s: Omit the symbol table and debug information.
-w: Omit the DWARF symbol table.

shortcoming is obviously, that you will lose all your debug information
if a crash occurs, you can not find the problem

1 Like

try uing upx, https://upx.github.io/

You could always use Tinygo if binary size is a concern.

TinyGo is neat, however there is a minimal chance your project would actually work with it because there is a lot of things unimplemented, like huge part of the standard library.

Upx I am using currently

It looks like you’re already using UPX to compress your executable. For further reduction, you might consider combining it with linker flags like -ldflags “-s -w” to strip debug information. Additionally, evaluating TinyGo could be worth it if your project is compatible, though be mindful of its limitations.