otel-cli icon indicating copy to clipboard operation
otel-cli copied to clipboard

Does the binary have to be so large?

Open dimaqq opened this issue 1 year ago • 1 comments

> go install github.com/equinix-labs/otel-cli@latest
...
> ls -halt ~/go/bin/otel-cli
-rwxr-xr-x@ 1 dima  staff    19M 26 Nov 12:42 /Users/dima/go/bin/otel-cli*/Users/dima/go/bin/otel-cli*
> strip ~/go/bin/otel-cli
> ls -halt ~/go/bin/otel-cli
-rwxr-xr-x@ 1 dima  staff    18M 26 Nov 12:42 /Users/dima/go/bin/otel-cli*

dimaqq avatar Nov 26 '24 03:11 dimaqq

Go binaries are statically built by default with no external dependency on system libraries.

You can save some space by building with debugging symbols stripped:go install -ldflags "-s -w" ./...

This cut the binary from 19M to 13M.

If you are using an operating system that supports it, you can try go install -buildmode=shared (optionally with the ldflags) for a dynamically linked binary.

displague avatar Jan 06 '25 22:01 displague