mirror of
https://github.com/golang/go
synced 2024-11-23 04:00:03 -07:00
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 <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Damien Neil <dneil@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
This commit is contained in:
parent
80d64adb79
commit
04f059f9ef
@ -124,7 +124,7 @@ func initConfVal() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Some operating systems always prefer the cgo resolver.
|
// Some operating systems always prefer the cgo resolver.
|
||||||
if goosPrefersCgo(runtime.GOOS) {
|
if goosPrefersCgo() {
|
||||||
confVal.preferCgo = true
|
confVal.preferCgo = true
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -155,8 +155,8 @@ func initConfVal() {
|
|||||||
|
|
||||||
// goosPreferCgo reports whether the GOOS value passed in prefers
|
// goosPreferCgo reports whether the GOOS value passed in prefers
|
||||||
// the cgo resolver.
|
// the cgo resolver.
|
||||||
func goosPrefersCgo(goos string) bool {
|
func goosPrefersCgo() bool {
|
||||||
switch goos {
|
switch runtime.GOOS {
|
||||||
// Historically on Windows and Plan 9 we prefer the
|
// Historically on Windows and Plan 9 we prefer the
|
||||||
// cgo resolver (which doesn't use the cgo tool) rather than
|
// cgo resolver (which doesn't use the cgo tool) rather than
|
||||||
// the go resolver. This is because originally these
|
// 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
|
// Neither resolver was explicitly requested
|
||||||
// and we have no preference.
|
// 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 {
|
if bytealg.IndexByteString(hostname, '\\') != -1 || bytealg.IndexByteString(hostname, '%') != -1 {
|
||||||
// Don't deal with special form hostnames
|
// Don't deal with special form hostnames
|
||||||
// with backslashes or '%'.
|
// with backslashes or '%'.
|
||||||
|
@ -341,18 +341,6 @@ func TestConfHostLookupOrder(t *testing.T) {
|
|||||||
nss: nssStr(t, "foo: bar"),
|
nss: nssStr(t, "foo: bar"),
|
||||||
hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}},
|
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.
|
// Issue 24393: make sure "Resolver.PreferGo = true" acts like netgo.
|
||||||
{
|
{
|
||||||
name: "resolver-prefergo",
|
name: "resolver-prefergo",
|
||||||
|
Loading…
Reference in New Issue
Block a user