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: Resolver.LookupIP: document should clarify the return values #43506

Open
yegle opened this issue Jan 5, 2021 · 5 comments · May be fixed by #45840
Open

net: Resolver.LookupIP: document should clarify the return values #43506

yegle opened this issue Jan 5, 2021 · 5 comments · May be fixed by #45840
Labels
Documentation help wanted NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@yegle
Copy link

yegle commented Jan 5, 2021

The current document on net.Resolver.LookupIP was not clear on the return values (i.e. what to expect when err is nil).

Looking into the source code, LookupIP uses internetAddrList here, and the comment for internetAddrList here does state the slice would contain at least one IP when err is nil.

We should duplicate the comment of internetAddrList to LookupIP.

yegle added a commit to yegle/go that referenced this issue Jan 5, 2021
The function will return at least one address when error is nil.

Fixes golang#43506
@gopherbot
Copy link

Change https://golang.org/cl/281552 mentions this issue: net: clarify Resolver.LookupIP return values

@ianlancetaylor
Copy link
Contributor

Why is this specific to Resolver.LookupIP? Seems like exactly the same issue arises for LookupHost, Resolver.LookupHost, LookupIP, Resolver.LookupIPAddr, LookupSRV, Resolver.LookupSRV, LookupMX, Resolver.LookupMX, LookupNS, Resolver.LookupNS, LookupTXT, Resolver.LookupTXT, LookupAddr, Resolver.LookupAddr, and possibly others.

@ianlancetaylor ianlancetaylor changed the title net.Resolver.LookupIP: document should clarify the return values net: Resolver.LookupIP: document should clarify the return values Jan 5, 2021
@ianlancetaylor ianlancetaylor added the NeedsFix The path to resolution is known, but the work has not been done. label Jan 5, 2021
@ianlancetaylor ianlancetaylor added this to the Backlog milestone Jan 5, 2021
@yegle
Copy link
Author

yegle commented Jan 5, 2021

It might apply to other functions as well, I only encountered this problem when using LookupIP.

@ianlancetaylor
Copy link
Contributor

My point is: let's try to find a clean fix for all relevant functions and methods, rather than just fixing one location. Thanks.

nerdatmath added a commit to nerdatmath/go that referenced this issue Apr 29, 2021
These functions always return at least one entry when err is nil.

Fixes golang#43506
@gopherbot
Copy link

Change https://golang.org/cl/314989 mentions this issue: net: clarify return values from Lookup* calls

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation help wanted NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
3 participants