Skip to content

Commit

Permalink
fix: support multi address (apache#1306)
Browse files Browse the repository at this point in the history
  • Loading branch information
xfstart07 committed Dec 12, 2021
1 parent 5cc35d6 commit 5684e20
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions common/url.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,17 @@ import (
"strings"
"sync"
"time"
)

import (
cm "github.com/Workiva/go-datastructures/common"

gxset "github.com/dubbogo/gost/container/set"
"github.com/jinzhu/copier"

perrors "github.com/pkg/errors"
"github.com/satori/go.uuid"
)

import (
"github.com/apache/dubbo-go/common/constant"
"github.com/apache/dubbo-go/common/logger"
uuid "github.com/satori/go.uuid"
)

// ///////////////////////////////
Expand Down Expand Up @@ -276,10 +274,13 @@ func NewURL(urlString string, opts ...Option) (*URL, error) {
s.Password, _ = serviceUrl.User.Password()
s.Location = serviceUrl.Host
s.Path = serviceUrl.Path
if strings.Contains(s.Location, ":") {
s.Ip, s.Port, err = net.SplitHostPort(s.Location)
if err != nil {
return &s, perrors.Errorf("net.SplitHostPort(url.Host{%s}), error{%v}", s.Location, err)
for _, location := range strings.Split(s.Location, ",") {
if strings.Contains(location, ":") {
s.Ip, s.Port, err = net.SplitHostPort(location)
if err != nil {
return &s, perrors.Errorf("net.SplitHostPort(url.Host{%s}), error{%v}", s.Location, err)
}
break
}
}
for _, opt := range opts {
Expand Down

0 comments on commit 5684e20

Please sign in to comment.