hostport is a simplified no-alloc version of net.SplitHostPort. Since we know that the address values have the correct form we can skip all the error checking.
(s string)
| 282 | // address values have the correct form we can |
| 283 | // skip all the error checking. |
| 284 | func hostport(s string) (host, port string) { |
| 285 | if s == "" { |
| 286 | return "", "" |
| 287 | } |
| 288 | n := strings.LastIndexByte(s, ':') |
| 289 | return s[:n], s[n+1:] |
| 290 | } |
| 291 | |
| 292 | // atoi is a replacement for strconv.Atoi/strconv.FormatInt |
| 293 | // which does not alloc. |