Categories     Timeline     RSS

Go static linking

With Go you get statically linked executables, right?

% go build 
% file unreadMail
unreadMail: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), dynamically linked, interpreter /lib64/, not stripped

% GOARCH=arm go build
% file unreadMail
unreadMail: ELF 32-bit LSB executable, ARM, EABI5 version 1 (SYSV), statically linked, not stripped

% CGO_ENABLED=0 go build
% file unreadMail
unreadMail: ELF 64-bit LSB executable, x86-64, version 1 (SYSV), statically linked, not stripped

The answer is a clear sometimes. Apparently the import of net causes the executable to be dynamically linked, since it uses CGO. Unless you disable CGO entirely. I would like an option to force go build to statically link or fail if not possible, please. Implicit behavioral changes are not my thing.

[Update 20170815:] You can still force Go to produce a statically linked executable by invoking an external linker and using a libc that fully supports static linkage, i.e. not GNU libc. My favorite so far is musl with its gcc wrapper:

CC=/usr/bin/musl-gcc go build -ldflags ' -linkmode=external -extldflags "-static"'

Not pretty, but better than dynamically linked executables…

Prowler Update

Turns out, I don’t really use the lower handles on my prowler, so I took them off. Probably the first time I used an angle grinder to cut.

Use for unreadMail

Or: “Print the internet”

Wherein I expand on the reason I wrote (lib)UnreadMail:

I wanted to reduce my time on electronic devices. A big chunk is devised to checking my mails, or at least that’s the initial intent - I use unreadMail now to automatically check my mail and print it out. I decide then if I need to go online or if it can wait. This setup only works because of proper spam control, otherwise things would be flooded. Here’s the rough outline of what I did:

I know that this wastes paper. But I also know, that the alternative wastes my time.


congstar said they would cancel my prepaid phone account because my last credit purchase was more than 15 months ago - unless I purchase credit now. Damn. I still have 10 Euros on there from the last time they forced me. In other words: In the last 15 months I have used about a quarter of the phone credit that an average user flings away in one month. ‘member when it seemed excessive to pay 20 DM in one month for your phone bill? I ‘member…


I wrote a small library in golang that implements barely enough IMAP to read unseen mail, that you can find here. It contains an example program that fetches all mails and prints the plain text to stdout.

I found the existing IMAP libraries too confusing to use - but having seen the RFCs concerning IMAP, that’s hardly the implementers’ fault. My stuff implements only the tiniest fraction of what IMAP encompasses. The standard is waaaay to big for my taste.