Shouldn't you check if hostPort is != "" before even trying the strconv?