logoalt Hacker News

dizhnyesterday at 8:38 PM1 replyview on HN

Static builds cannot have cgo too if I am not mistaken.


Replies

agwayesterday at 9:07 PM

The following go flags let you build statically-linked cgo binaries, provided that all the C libraries that you're using support static linking and don't call the NSS functions in glibc:

-tags netgo,osusergo -linkmode external -extldflags -static

I regularly compile (cross-compile, even) static Go binaries that use the cgo sqlite package. But it's certainly a lot simpler if you can avoid cgo.