Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.Sign up
net: a nsswitch.conf hosts: entry with 'myhostname' forces cgo lookups for LookupPort() and others #13623
net.LookupPort(), net.LookupCNAME(), and net.LookupAddr() all wind up trying to decide whether to use cgo lookups or the pure Go lookups by calling hostLookupOrder("") (via canUseCgo()). Because the empty string contains no dots, it matches the 'nsswitch.conf hosts line contains myhostname and hostname to be looked up contains no dots' check that forces the use of cgo. I suspect that this is unintentional, as at least the port lookup isn't a hostname related one and so won't actually use the myhostname NSS module.
(It may be necessary for LookupCNAME() to care about myhostname here, unlike at least port lookup.)