LaurenceLiZhixin commented on code in PR #1804: URL: https://github.com/apache/dubbo-go/pull/1804#discussion_r841406260
########## remoting/xds/common/model.go: ########## @@ -0,0 +1,57 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package common + +import ( + "strings" +) + +type Addr struct { + HostnameOrIP string + Port string +} + +func NewAddr(addr string) Addr { + addrs := strings.Split(addr, ":") + return Addr{ + HostnameOrIP: addrs[0], + Port: addrs[1], + } +} + +func (a *Addr) String() string { Review Comment: 我认为还是需要封装一个自己的Addr,用来以字符串形式存储“地址 + 端口” 官方提供的net.TCPAddr, 其ip必须是真实的ip,并不是字符串封装的地址例如"istiod.istio-system.svc.cluster.local",不能在我的场景使用。 上面几个评论,使用官方库来进行地址和ip+port的转换,这个我会修复。 但我还是希望保留这个Addr 对象。 @AlexStocks -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
