The Road to CGO-Less is Paved
summary
Disabling CGo does not guarantee a C-free, static binary across platforms: building with CGO_ENABLED=0 can still pull in libc or DLLs on macOS, OpenBSD and Windows, and DNS and user lookups may switch between pure-Go and C-backed resolvers unless you set build tags like netgo and osusergo. Evidence comes from ldd outputs, runtime linker directives and differing behavior between Go 1.19 and Go 1.20. On Linux a fully static result is more likely, but results vary and change with Go releases.
AI-written summary · about
chapters (14)
- 0:00Avoiding C in Go
- 1:03Myth of CGO-free binaries
- 2:29OS user package differences
- 7:09Syscalls truly C-free?
- 10:01Go’s syscall across OSes
- 13:38Darwin’s syscall API limits
- 15:25Windows syscalls and kernel32
- 17:14Net package DNS resolver
- 20:48DNS without CGO
- 23:00Inconsistent host lookups
- 25:44Static builds and CGO
- 27:06Go 1.20 improvements
- 28:32C compiler in CGO builds
- 29:57Disabling CGO consequences
related talks
26mWrite Once, Compile Lots, Run Anywhere
20m"Go(lang) for mobile"
46mLessons learnt using Go
51mFrom assembler to C++: structure and optimization of CGo ☠️
34mHigh-load CGo: calling nonblocking C/C++ code without surprise ☠️
26mGo is Boring... And That's Fantastic!
24mFinal Go panel - part 1
56mGet Go-ing
