Skip to content
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: there should be a net.ResolveAddr() function #5133

Closed
siebenmann opened this issue Mar 26, 2013 · 8 comments
Closed

net: there should be a net.ResolveAddr() function #5133

siebenmann opened this issue Mar 26, 2013 · 8 comments

Comments

@siebenmann
Copy link

Now that there is net.DialOpt() and net.LocalAddress(), it would be quite
convenient to have a net.ResolveAddr() function so that you can generically
create the local address Addr that net.LocalAddress() wants. Right now
you have to write code that switches on the network type to call the
appropriate Resolve<whatever>Addr() function; among other issues, this
burns knowledge of what network types the net package supports into your
own code.

Basically all of the code necessary already exists in the internal
net resolveAddr() function; all that would be necessary would be
exposing a public interface to it.
@davecheney
Copy link
Contributor

Comment 1:

mikio / rsc - do you think that it is appropriate to add this function to the net
package in the 1.2 cycle ?

Status changed to Thinking.

@mikioh
Copy link
Contributor

mikioh commented May 31, 2013

Comment 2:

I think API surface is fine but I'm afraid this API will have the same issue which
existing ResolveProtocolAddr API has, that is that how could we select an appropriate
address for any purposes without any preferences such as a target/destination address,
routing information, etc when the user passes a DNS reg. name instead of a literal IP
address.

@rsc
Copy link
Contributor

rsc commented Jul 30, 2013

Comment 3:

I can't make sense of this report: I don't see a net.DialOpt or a net.LocalAddress.

@siebenmann
Copy link
Author

Comment 4:

My initial report referred to the API of an intermediate version of the
net package. The current API is that to customize aspects of net.Dial()
you create a net.Dialer struct with a LocalAddr member then call its
.Dial(). But you're still on your own to create a suitable net.Addr
address for the LocalAddr member.
(Hopefully this makes sense now.)

@rsc
Copy link
Contributor

rsc commented Nov 27, 2013

Comment 5:

Labels changed: added go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 6:

Labels changed: added release-none, removed go1.3maybe.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 7:

Labels changed: added repo-main.

@bradfitz
Copy link
Contributor

bradfitz commented Feb 2, 2017

Does net.Resolver in Go 1.8 solve this?

If not, please file a new bug about what's tedious to do with Go 1.8 (with sample code) and reference this bug in your new bug report.

@bradfitz bradfitz closed this as completed Feb 2, 2017
@golang golang locked and limited conversation to collaborators Feb 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants