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 inconsistent error conditions #18040

adamhassel opened this issue Nov 24, 2016 · 2 comments

net: SplitHostPort has inconsistent error conditions #18040

adamhassel opened this issue Nov 24, 2016 · 2 comments


Copy link

@adamhassel adamhassel commented Nov 24, 2016

In net.SplitHostPort, giving a string with a port defined, but no hostname (e.g. ":80"), results in an empty host, a port and an empty error. Providing a hostname (or IP) with no port (e.g. ""), results in an error.

I would think that both of these scenarios should behave in the same way: either both should return an error, or both should return an empty value and no error.

Copy link

@bradfitz bradfitz commented Nov 24, 2016

I think it's pretty consistent: if there's no colon, it returns an error:

In any case, we've had this same behavior for 4+ years now, so I don't think we want to change it now.

The new URL.Port and URL.Hostname methods in Go 1.8 should help with this, though, since I think they're more likely doing what you want.

@bradfitz bradfitz closed this Nov 24, 2016
Copy link

@minux minux commented Nov 24, 2016

@golang golang locked and limited conversation to collaborators Nov 24, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants