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

Comments

Projects
None yet
5 participants
@okdave
Copy link
Contributor

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

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2016

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

@okdave okdave self-assigned this Mar 15, 2016

@okdave

This comment has been minimized.

Copy link
Contributor Author

commented Mar 15, 2016

Yes, happy to.

@bradfitz

This comment has been minimized.

Copy link
Member

commented Mar 15, 2016

I'm happy to review, too.

@rsc

This comment has been minimized.

Copy link
Contributor

commented Mar 15, 2016

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

@gopherbot gopherbot closed this in 5630cb7 Mar 15, 2016

mholt added a commit to mholt/caddy that referenced this issue Mar 16, 2016

@golang golang locked and limited conversation to collaborators Mar 19, 2017

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
You can’t perform that action at this time.