Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does the binary have to be so large? #367

Open
dimaqq opened this issue Nov 26, 2024 · 1 comment
Open

Does the binary have to be so large? #367

dimaqq opened this issue Nov 26, 2024 · 1 comment

Comments

@dimaqq
Copy link

dimaqq commented Nov 26, 2024

> 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*
@displague
Copy link
Member

displague commented Jan 6, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants