Go executable file is so large

I don’t want to use upx or strip to reduce the size of executable file. If I use dynamic-link-library, what problems will I have?

Welcome to Golang Bridge. :rocket: :fireworks:

You need to ensure all Go Plugins are available at your client alongside with your Go executable.

Hence, this will leads to dependency managements. That also means a slightly more complicated CI builds.


  1. Go’s beauty is to statically compile everything into a single binary so that your client can just use that one single file instead of reading a lot of manuals or a bunch of pre-setup.
  2. I’m assuming your “large” means >500MB. Otherwise, it’s not large.
1 Like

I agree with Holloway’s side notes and have one of my own to add.

If you aren’t already, try passing the -s and -w flags to the linker to strip debug information. That will help reduce the size.

go build -ldflags="-s -w"

I use “objcopy --keep-only-debug” to save debug info and then strip the executable file.

It’s necessary to reduce the size of the executable file for me, whenever it’s 100MB or 200 MB

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