Started adding tests

This commit is contained in:
Matthew Holt
2015-01-13 17:25:55 -07:00
parent 04162aaa79
commit 7b3d005662
3 changed files with 39 additions and 12 deletions
+5 -11
View File
@@ -66,18 +66,12 @@ func (p *parser) err(kind, msg string) error {
}
// parseAddress takes a host:port string (val), and returns the host
// and port as separate values. If either value that is missing, the
// default will be used.4
func (p *parser) parseAddress(val string) (string, string) {
if val == "" {
return defaultHost, defaultPort
}
// and port as separate values. Empty strings can be returned if
// either is missing.
func parseAddress(val string) (string, string) {
parts := strings.SplitN(val, ":", 3)
if parts[0] == "" {
parts[0] = defaultHost
}
if len(parts) == 1 || parts[1] == "" {
return parts[0], defaultPort
if len(parts) == 1 {
return parts[0], ""
} else {
return parts[0], parts[1]
}