From: Ian Lance Taylor Date: Fri, 28 Apr 2023 17:29:58 +0000 (-0700) Subject: net: don't recheck goosPrefersCgo in hostLookupOrder X-Git-Tag: go1.21rc1~730 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=04f059f9efbb2a202ddb6a3c6f87efa8073e562f;p=gostls13.git net: don't recheck goosPrefersCgo in hostLookupOrder We only did it for testing. Remove the single test that required it. Change-Id: Ib6c3a2debfd3f48e95af37f23fdfde847ff87a41 Reviewed-on: https://go-review.googlesource.com/c/go/+/490395 Run-TryBot: Ian Lance Taylor TryBot-Result: Gopher Robot Reviewed-by: Bryan Mills Reviewed-by: Damien Neil Auto-Submit: Ian Lance Taylor --- diff --git a/src/net/conf.go b/src/net/conf.go index 6386078132..d11a568502 100644 --- a/src/net/conf.go +++ b/src/net/conf.go @@ -124,7 +124,7 @@ func initConfVal() { } // Some operating systems always prefer the cgo resolver. - if goosPrefersCgo(runtime.GOOS) { + if goosPrefersCgo() { confVal.preferCgo = true return } @@ -155,8 +155,8 @@ func initConfVal() { // 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 @@ -227,13 +227,6 @@ func (c *conf) hostLookupOrder(r *Resolver, hostname string) (ret hostLookupOrde // 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 '%'. diff --git a/src/net/conf_test.go b/src/net/conf_test.go index 6c9d247713..08d774bfe2 100644 --- a/src/net/conf_test.go +++ b/src/net/conf_test.go @@ -341,18 +341,6 @@ func TestConfHostLookupOrder(t *testing.T) { 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",