|
|
@@ -3,6 +3,7 @@ package gocql
|
|
|
import (
|
|
|
"fmt"
|
|
|
"log"
|
|
|
+ "regexp"
|
|
|
"strings"
|
|
|
"sync"
|
|
|
"time"
|
|
|
@@ -145,7 +146,8 @@ func NewSimplePool(cfg *ClusterConfig) ConnectionPool {
|
|
|
//defer the remaining connections to cluster.fillPool()
|
|
|
for i := 0; i < len(cfg.Hosts); i++ {
|
|
|
addr := strings.TrimSpace(cfg.Hosts[i])
|
|
|
- if strings.Index(addr, ":") < 0 {
|
|
|
+ port_appended, _ := regexp.MatchString(`:\d*$`, addr)
|
|
|
+ if !port_appended {
|
|
|
addr = fmt.Sprintf("%s:%d", addr, cfg.Port)
|
|
|
}
|
|
|
|
|
|
@@ -236,7 +238,8 @@ func (c *SimplePool) fillPool() {
|
|
|
//Walk through list of defined hosts
|
|
|
for host := range c.hosts {
|
|
|
addr := strings.TrimSpace(host)
|
|
|
- if strings.Index(addr, ":") < 0 {
|
|
|
+ port_appended, _ := regexp.MatchString(`:\d*$`, addr)
|
|
|
+ if !port_appended {
|
|
|
addr = fmt.Sprintf("%s:%d", addr, c.cfg.Port)
|
|
|
}
|
|
|
|