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: SplitHostPort has returns strange host when err != nil #14827

Closed
okdave opened this issue Mar 15, 2016 · 4 comments
Closed

net: SplitHostPort has returns strange host when err != nil #14827

okdave opened this issue Mar 15, 2016 · 4 comments
Milestone

Comments

@okdave
Copy link
Contributor

okdave commented Mar 15, 2016

When SplitHostPost is given an invalid input (for example, and IPv6 address without a port), it returns an invalid/strange value for host alongside the error. This differs from many other funcs in the standard library (where usually zero values are returned unless documented otherwise), and invites mistakes if the user doesn't check the error.

For example in host, port, err := net.SplitHostPort("2001:db8::ff00:42:8329") host is "2001:db8::ff00:42".

@mikioh mikioh added this to the Go1.7 milestone Mar 15, 2016
@mikioh
Copy link
Contributor

mikioh commented Mar 15, 2016

Thanks for the report. Are you interested in fixing this issue?

@okdave okdave self-assigned this Mar 15, 2016
@okdave
Copy link
Contributor Author

okdave commented Mar 15, 2016

Yes, happy to.

@bradfitz
Copy link
Contributor

I'm happy to review, too.

@rsc
Copy link
Contributor

rsc commented Mar 15, 2016

Yes, please fix this to avoid setting host until success is assured.

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

5 participants