}
// Some operating systems always prefer the cgo resolver.
- if goosPrefersCgo(runtime.GOOS) {
+ if goosPrefersCgo() {
confVal.preferCgo = true
return
}
// goosPreferCgo reports whether the GOOS value passed in prefers
// the cgo resolver.
-func goosPrefersCgo(goos string) bool {
- switch goos {
+func goosPrefersCgo() bool {
+ switch runtime.GOOS {
// Historically on Windows and Plan 9 we prefer the
// cgo resolver (which doesn't use the cgo tool) rather than
// the go resolver. This is because originally these
// Neither resolver was explicitly requested
// and we have no preference.
- // For testing purposes only, recheck the GOOS.
- // This lets TestConfHostLookupOrder test different
- // GOOS values.
- if goosPrefersCgo(c.goos) {
- return hostLookupCgo, nil
- }
-
if bytealg.IndexByteString(hostname, '\\') != -1 || bytealg.IndexByteString(hostname, '%') != -1 {
// Don't deal with special form hostnames
// with backslashes or '%'.
nss: nssStr(t, "foo: bar"),
hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}},
},
- // Android should always use cgo.
- {
- name: "android",
- c: &conf{
- goos: "android",
- },
- resolv: defaultResolvConf,
- nss: nssStr(t, ""),
- hostTests: []nssHostTest{
- {"x.com", "myhostname", hostLookupCgo},
- },
- },
// Issue 24393: make sure "Resolver.PreferGo = true" acts like netgo.
{
name: "resolver-prefergo",