Go is portable, until it isn't | Simple Observability

An exploration of Go's portability limits when integrating with system-specific C libraries like libsystemd and dealing with glibc vs. musl systems.

Once you use CGO, portability is gone. Your binary is no longer staticly compiled.

This can happen subtley without you knowing it. If you use a function in the standard library that happens to call into a CGO function, you are no longer static.

This happens with things like os.UserHomeDir or some networking things like DNS lookups.

You can "force" go to do static compiling by disabling CGO, but that means you can't use _any_ CGO. Which may not work if you require it for certain things like sqlite.

There are at least a couple of ways to run SQLite without CGO.
I think the standard answer here is modernc.org/sqlite.