AlexStocks commented on code in PR #3186:
URL: https://github.com/apache/dubbo-go/pull/3186#discussion_r2780305855
##########
global/router_config.go:
##########
@@ -53,6 +57,31 @@ type ConditionRule struct {
To []ConditionRuleTo `yaml:"to" json:"to,omitempty" property:"to"`
}
+// Equal checks if two ConditionRule instances are equal.
Review Comment:
```go
func (x *ConditionRule) Equal(t *ConditionRule) bool {
// 合并 nil 判断
if x == nil || t == nil {
return x == t
}
// 比较 From 字段
if !reflect.DeepEqual(x.From, t.From) {
return false
}
// 比较 To 字段的长度
if len(x.To) != len(t.To) {
return false
}
// 如果 To 字段为空,直接返回 true
if len(x.To) == 0 {
return true
}
// 遍历 To 字段的每个元素进行比较
for i := range x.To {
if !reflect.DeepEqual(x.To[i], t.To[i]) {
return false
}
}
return true
}
```
这是我让 chatgpt 改进后的代码,你瞧下哈
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]