-
Notifications
You must be signed in to change notification settings - Fork 17.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
net: add context-aware Dialer methods DialTCP, DialUDP, DialIP, DialUnix #49097
Comments
Could you give more information about the reason you want to add them and how they will be used? Thanks. |
such as: ctx, cancel := context.WithTimeout(context.Background(), 30000*time.Millisecond)
defer cancel()
taddr := &net.TCPAddr{}
c, err := net.DialTCPContext(ctx, "tcp", nil, taddr)
... It can realize the timeout processing of DialTCP. DialUDP and DialIP are similary like this. |
Use And I hope I can use |
We could add these to net.Dialer, which is what we are using instead of adding new context-aware versions of all the top-level functions. The specific methods we'd need to add would be:
Note that all take contexts but don't say "Context" in the name. Thoughts? |
This proposal has been added to the active column of the proposals project |
Any objections to #49097 (comment) ? |
With the introduction of net/netip, we should probably make these new methods use those types (netip.AddrPort) instead of TCPAddr, UDPAddr. |
It sounds like we should be adding these methods on net.Dialer:
Does anyone object to these? |
Based on the discussion above, this proposal seems like a likely accept. |
No change in consensus, so accepted. 🎉 |
Change https://golang.org/cl/377155 mentions this issue: |
Change https://go.dev/cl/490975 mentions this issue: |
Where is this proposal at? Its been accepted, but #50534 has been closed. |
The accepted proposal is to add new methods to
new.Dialer
: #49097 (comment)--
Such like given below:
The text was updated successfully, but these errors were encountered: