Skip to content

Commit 04f059f

Browse files
ianlancetaylorgopherbot
authored andcommitted
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 <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Bryan Mills <[email protected]> Reviewed-by: Damien Neil <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 80d64ad commit 04f059f

File tree

2 files changed

+3
-22
lines changed

2 files changed

+3
-22
lines changed

src/net/conf.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ func initConfVal() {
124124
}
125125

126126
// Some operating systems always prefer the cgo resolver.
127-
if goosPrefersCgo(runtime.GOOS) {
127+
if goosPrefersCgo() {
128128
confVal.preferCgo = true
129129
return
130130
}
@@ -155,8 +155,8 @@ func initConfVal() {
155155

156156
// goosPreferCgo reports whether the GOOS value passed in prefers
157157
// the cgo resolver.
158-
func goosPrefersCgo(goos string) bool {
159-
switch goos {
158+
func goosPrefersCgo() bool {
159+
switch runtime.GOOS {
160160
// Historically on Windows and Plan 9 we prefer the
161161
// cgo resolver (which doesn't use the cgo tool) rather than
162162
// the go resolver. This is because originally these
@@ -227,13 +227,6 @@ func (c *conf) hostLookupOrder(r *Resolver, hostname string) (ret hostLookupOrde
227227
// Neither resolver was explicitly requested
228228
// and we have no preference.
229229

230-
// For testing purposes only, recheck the GOOS.
231-
// This lets TestConfHostLookupOrder test different
232-
// GOOS values.
233-
if goosPrefersCgo(c.goos) {
234-
return hostLookupCgo, nil
235-
}
236-
237230
if bytealg.IndexByteString(hostname, '\\') != -1 || bytealg.IndexByteString(hostname, '%') != -1 {
238231
// Don't deal with special form hostnames
239232
// with backslashes or '%'.

src/net/conf_test.go

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -341,18 +341,6 @@ func TestConfHostLookupOrder(t *testing.T) {
341341
nss: nssStr(t, "foo: bar"),
342342
hostTests: []nssHostTest{{"google.com", "myhostname", hostLookupCgo}},
343343
},
344-
// Android should always use cgo.
345-
{
346-
name: "android",
347-
c: &conf{
348-
goos: "android",
349-
},
350-
resolv: defaultResolvConf,
351-
nss: nssStr(t, ""),
352-
hostTests: []nssHostTest{
353-
{"x.com", "myhostname", hostLookupCgo},
354-
},
355-
},
356344
// Issue 24393: make sure "Resolver.PreferGo = true" acts like netgo.
357345
{
358346
name: "resolver-prefergo",

0 commit comments

Comments
 (0)