the size of the files compiled in GO

217 views
Skip to first unread message

jarek...@gmail.com

unread,
Apr 18, 2020, 1:26:11 PM4/18/20
to golang-nuts
Why does the simple Hello world program take 2 MB after compilation?

Chris Burkert

unread,
Apr 18, 2020, 1:29:56 PM4/18/20
to jarek...@gmail.com, golang-nuts

<jarek...@gmail.com> schrieb am Sa. 18. Apr. 2020 um 19:25:
Why does the simple Hello world program take 2 MB after compilation?

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/4d572066-f044-4aa8-8661-5653381b6d81%40googlegroups.com.

Josh Kamau

unread,
Apr 18, 2020, 4:11:53 PM4/18/20
to Chris Burkert, golang-nuts, jarek...@gmail.com

Because golang has a runtime that includes a garbage collector, goroutine scheduler etc

Jan Flyborg

unread,
Apr 19, 2020, 9:24:37 AM4/19/20
to golang-nuts

You can probably make it much smaller by just stripping the binary, and for those cases where you want it to be even smaller, you can always use UPX (but that comes with a price in the form of slower startup and higher memory usage).

serhat...@gmail.com

unread,
Apr 19, 2020, 4:18:29 PM4/19/20
to golang-nuts
It is one of the first things that people who start golang wonder, also another feature that makes this language unique.

Amnon Baron Cohen

unread,
Apr 20, 2020, 2:45:07 AM4/20/20
to golang-nuts
Executable size for small programs is not a top priority in gc.
So if you care about executable size (e.g. if your code runs on microcontrollers,
or WASM), you may want to have a look at https://tinygo.org/ .
Reply all
Reply to author
Forward
0 new messages