You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What steps will reproduce the problem?
See http://play.golang.org/p/gvAUHRN19-
What is the expected output?
I would expect, as the result of net.SplitHostPort("[de:ad:be:ef::ca:fe]"),
the error message "missing port in address ...".
What do you see instead?
"too many colons in address ..."
Which compiler are you using (5g, 6g, 8g, gccgo)?
Which operating system are you using?
Which version are you using? (run 'go version')
8g, Linux, +835576f9bf0e
Please provide any additional information below.
The modified function below changes the behaviour. After the
test for brackets around host fails, the function also tests
for brackets around hostport now.
func splitHostPort(hostport string) (host, port, zone string, err error) {
// The port starts after the last colon.
i := last(hostport, ':')
if i < 0 {
err = &AddrError{"missing port in address", hostport}
return
}
host, port = hostport[:i], hostport[i+1:]
// Can put brackets around host ...
switch {
case insideBrackets(host):
host = host[1 : len(host)-1]
case insideBrackets(hostport):
err = &AddrError{"missing port in address", hostport}
default:
// ... but if there are no brackets, no colons.
if byteIndex(host, ':') >= 0 {
err = &AddrError{"too many colons in address", hostport}
return
}
}
return
}
func insideBrackets(s string) bool {
return len(s) > 0 && s[0] == '[' && s[len(s)-1] == ']'
}
The text was updated successfully, but these errors were encountered:
by mt4swm:
The text was updated successfully, but these errors were encountered: