code: func tryConnect(machines []string, password string, timeout bool) (redis.Conn, int, error) {
  	var err error
  	for _, address := range machines {
  		var conn redis.Conn
  		var db int
  
  		idx := strings.Index(address, "/")
  		if idx != -1 {
  			// a database is provided
  			db, err = strconv.Atoi(address[idx+1:])
  			if err == nil {
  				address = address[:idx]
  			}
  		}
  
  		network := "tcp"
  		if _, err = os.Stat(address); err == nil {
  			network = "unix"
  		}
  		log.Debug(fmt.Sprintf("Trying to connect to redis node %s", address))
  
  		var dialops []redis.DialOption
  		if timeout {
  			dialops = []redis.DialOption{
  				redis.DialConnectTimeout(time.Second),
  				redis.DialReadTimeout(time.Second),
  				redis.DialWriteTimeout(time.Second),
  				redis.DialDatabase(db),
  			}
  		} else {
  			dialops = []redis.DialOption{
  				redis.DialConnectTimeout(time.Second),
  				redis.DialWriteTimeout(time.Second),
  				redis.DialDatabase(db),
  			}
  		}
  
  		if password != "" {
  			dialops = append(dialops, redis.DialPassword(password))
  		}
  
  		conn, err = redis.Dial(network, address, dialops...)
  
  		if err != nil {
  			continue
  		}
  		return conn, db, nil
  	}
  	return nil, 0, err
  }
docs: // Iterate through `machines`, trying to connect to each in turn.
  // Returns the first successful connection or the last error encountered.
  // Assumes that `machines` is non-empty.