DNS Resolution in Go and Cgo
May 24, 2017Ryan Law

Summary
This post details an investigation into DNS resolution differences between Go's native resolver, Cgo, and C. It explains RFC 6724 (3484) and its impact on IP address selection. The authors demonstrate through code examples and output that disabling IPv6 alters the IP address sorting order for Cgo and C resolvers, while having no effect on Go's native resolver. The core issue identified is Go's native resolver's partial implementation of RFC 6724, specifically its lack of source address selection, which differs from the glibc implementation used by Cgo/C.