Re:sqlite: A CGo-free port of SQLite/SQLite3
by dizhn on Sunday June 07, 2026 @04:38PM
(#48438303)
Static builds cannot have cgo too if I am not mistaken.
[ Parent
| on HN ]
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.