The source code

src/net/conf.go

func initConfVal() { ... if runtime.GOOS ! = "openbsd" { confVal.nss = parseNSSConfFile("/etc/nsswitch.conf") } ... if os.IsNotExist(nss.err) || (nss.err == nil && len(srcs) == 0) { if c.goos == "solaris" { // illumos defaults to "nis [NOTFOUND=return] files" return fallbackOrder } if c.goos == "linux" { return hostLookupDNSFiles } return hostLookupFilesDNS } ... }Copy the code

src/net/nss.go

func parseNSSConfFile(file string) *nssConf { f, err := os.Open(file) if err ! = nil { return &nssConf{err: err} } defer f.Close() return parseNSSConf(f) }Copy the code

why

/etc/nsswitch.conf does not exist in Alpine, resulting in a query from DNS first and then file