You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To resolve an address, it needs a communication between local host and name server. When the routes changed or something else makes the address being unreachable, or there is loss of UDP datagram, there will be a high delay (maybe the goroutine will never wake up again).
What I can do now is use net.DialContext() with a deadline or net.Dialer. But when I want to only resolve the host name/domain, net.Resolve*Addr() or net.Lookup*() never timeout.
I read source code of net and I found net.Resolve*Addr() does have some code about context:
/src/net/tcpsock.go:6456funcResolveTCPAddr(net, addrstring) (*TCPAddr, error) {
57switchnet {
58case"tcp", "tcp4", "tcp6":
59case"": // a hint wildcard for Go 1.0 undocumented behavior60net="tcp"61default:
62returnnil, UnknownNetworkError(net)
63 }
64addrs, err:=internetAddrList(context.Background(), net, addr)
65iferr!=nil {
66returnnil, err67 }
68returnaddrs.first(isIPv4).(*TCPAddr), nil69 }
Can we export the context argument?
Maybe add something like net.ResolveTCPAddrContext() ? or an interface called, maybe, Resolver?
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
1.7.4
What operating system and processor architecture are you using (go env)?
To resolve an address, it needs a communication between local host and name server. When the routes changed or something else makes the address being unreachable, or there is loss of UDP datagram, there will be a high delay (maybe the goroutine will never wake up again).
What I can do now is use
net.DialContext()
with a deadline ornet.Dialer
. But when I want to only resolve the host name/domain,net.Resolve*Addr()
ornet.Lookup*()
never timeout.I read source code of
net
and I foundnet.Resolve*Addr()
does have some code about context:Can we export the context argument?
Maybe add something like
net.ResolveTCPAddrContext()
? or an interface called, maybe,Resolver
?Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version
)?1.7.4
What operating system and processor architecture are you using (
go env
)?The text was updated successfully, but these errors were encountered: