/tinyhelloworld

A very synthetic, but very small hello world in Go. **It takes 91 bytes when compiled (as a static binary).**

Primary LanguageAssemblyCreative Commons Zero v1.0 UniversalCC0-1.0

CC0
To the extent possible under law, Dmitrii Okunev has waived all copyright and related or neighboring rights to "A very synthetic, but very small hello world on Go. This work is published from: Ireland".

Quick start

$ rm -f tinyhelloworld
$ docker build -t build-go-tinyhelloworld . && docker run -v "$(pwd):/project" build-go-tinyhelloworld
$ stat -c %s ./tinyhelloworld
91
$ ./tinyhelloworld
Hello, world!

OR

$ rm -f tinyhelloworld
$ make all
$ stat -c %s ./tinyhelloworld
91
$ ./tinyhelloworld
Hello, world!

Hexdump

$ hexdump -C tinyhelloworld 
00000000  7f 45 4c 46 01 00 00 00  00 00 00 00 00 00 00 01  |.ELF............|
00000010  02 00 03 00 00 00 00 01  2e 00 00 01 04 00 00 00  |................|
00000020  00 00 00 00 00 00 00 00  00 00 20 00 01 00 e8 07  |.......... .....|
00000030  00 00 00 31 c0 31 db 40  cd 80 53 6a 04 58 31 db  |...1.1.@..Sj.X1.|
00000040  43 6a 0e 5a b9 4d 00 00  01 cd 80 5b c3 48 65 6c  |Cj.Z.M.....[.Hel|
00000050  6c 6f 2c 20 77 6f 72 6c  64 21 0a                 |lo, world!.|
0000005b

Comments

elf.asm is just ELF-headers and a wrapper to call the main().

The binary could be even less if we place our useful data right into the ELF headers (see an example).

See also

Why is Go binary so big

A collection of articles explains some details about Go: