Skip to content

Commit 6536c20

Browse files
mateusz834gopherbot
authored andcommitted
net: improve GODEBUG=netdns=1 debug messages
Fixes #69680 Change-Id: I73b0506c7a3245ba282cffabe47543f5fce86692 GitHub-Last-Rev: 4c6a1a4 GitHub-Pull-Request: #69684 Reviewed-on: https://go-review.googlesource.com/c/go/+/616263 LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Auto-Submit: Ian Lance Taylor <[email protected]>
1 parent 0fb3386 commit 6536c20

File tree

1 file changed

+20
-9
lines changed

1 file changed

+20
-9
lines changed

src/net/conf.go

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,19 +93,30 @@ func initConfVal() {
9393
if confVal.dnsDebugLevel > 1 {
9494
println("go package net: confVal.netCgo =", confVal.netCgo, " netGo =", confVal.netGo)
9595
}
96+
if dnsMode != "go" && dnsMode != "cgo" && dnsMode != "" {
97+
println("go package net: GODEBUG=netdns contains an invalid dns mode, ignoring it")
98+
}
9699
switch {
97-
case confVal.netGo:
98-
if netGoBuildTag {
99-
println("go package net: built with netgo build tag; using Go's DNS resolver")
100+
case netGoBuildTag || !cgoAvailable:
101+
if dnsMode == "cgo" {
102+
println("go package net: ignoring GODEBUG=netdns=cgo as the binary was compiled without support for the cgo resolver")
103+
} else {
104+
println("go package net: using the Go DNS resolver")
105+
}
106+
case netCgoBuildTag:
107+
if dnsMode == "go" {
108+
println("go package net: GODEBUG setting forcing use of the Go resolver")
100109
} else {
101-
println("go package net: GODEBUG setting forcing use of Go's resolver")
110+
println("go package net: using the cgo DNS resolver")
102111
}
103-
case !cgoAvailable:
104-
println("go package net: cgo resolver not supported; using Go's DNS resolver")
105-
case confVal.netCgo || confVal.preferCgo:
106-
println("go package net: using cgo DNS resolver")
107112
default:
108-
println("go package net: dynamic selection of DNS resolver")
113+
if dnsMode == "go" {
114+
println("go package net: GODEBUG setting forcing use of the Go resolver")
115+
} else if dnsMode == "cgo" {
116+
println("go package net: GODEBUG setting forcing use of the cgo resolver")
117+
} else {
118+
println("go package net: dynamic selection of DNS resolver")
119+
}
109120
}
110121
}()
111122
}

0 commit comments

Comments
 (0)