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: LookupHost returns error when given an IP. #684

Closed
gopherbot opened this issue Mar 20, 2010 · 6 comments
Closed

net: LookupHost returns error when given an IP. #684

gopherbot opened this issue Mar 20, 2010 · 6 comments
Milestone

Comments

@gopherbot
Copy link

by emilliken:

Perhaps rather than giving an error, it can act the same way as C's 
gethostbyname(name)?  From the gethostbyname() manpage:
 
If name is an IPv4 or IPv6 address, no lookup is performed and 
gethostbyname() simply copies name into the  h_name  field  and  its
struct  in_addr equivalent into the h_addr_list[0] field of the returned
hostent structure.

Which revision are you using?
changeset:   5092:c4e62b8f7f1c
@rsc
Copy link
Contributor

rsc commented Mar 22, 2010

Comment 1:

Isn't that what ParseIP is for?
What's the bigger context here?

@gopherbot
Copy link
Author

Comment 2 by emilliken:

I had written a program that needed to Dial() the same host over and over.  To avoid 
doing a dns lookup inside Dial() every time, I would call net.LookupHost() and pass the 
returned IP to Dial.  The program failed when I would call net.LookupHost with an IP, 
which was unexpected (I was used to the gethostbyname behavior).  Not a big deal, but 
perhaps the behavior should be documented.

@rsc
Copy link
Contributor

rsc commented Mar 22, 2010

Comment 3:

You can avoid both the DNS lookup and even the parsing if instead you use
net.ResolveTCPAddr (or 
ResolveUDPAddr) and net.DialTCP (or net.DialUDP).

@gopherbot
Copy link
Author

Comment 4 by emilliken:

ResolveTCPAddr is what I was looking for, thanks.

@rsc
Copy link
Contributor

rsc commented Mar 25, 2010

Comment 5:

Status changed to WorkingAsIntended.

@mikioh mikioh changed the title net.LookupHost returns error when given an IP. net: LookupHost returns error when given an IP. Aug 5, 2015
@mikioh mikioh added this to the Go1.5 milestone Aug 5, 2015
@mikioh
Copy link
Contributor

mikioh commented Aug 5, 2015

Merged into #11335.

@golang golang locked and limited conversation to collaborators Aug 5, 2016
This issue was closed.
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

3 participants