This is an automated email from the ASF dual-hosted git repository.
Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git
The following commit(s) were added to refs/heads/develop by this push:
new f2ec52e4c fix: correct inverted guard in
WithRegistryIDs/WithProtocolIDs (#3604)
f2ec52e4c is described below
commit f2ec52e4c3d3e53af878eed891e4654164a59afb
Author: MaoMeng <[email protected]>
AuthorDate: Fri Aug 7 10:35:45 2026 +0800
fix: correct inverted guard in WithRegistryIDs/WithProtocolIDs (#3604)
---
server/options.go | 4 ++--
server/options_test.go | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/server/options.go b/server/options.go
index 869a2d11f..93ba8add1 100644
--- a/server/options.go
+++ b/server/options.go
@@ -619,7 +619,7 @@ func WithInterface(interfaceName string) ServiceOption {
// todo(DMwangnima): think about a more ideal configuration style
func WithRegistryIDs(registryIDs []string) ServiceOption {
return func(cfg *ServiceOptions) {
- if len(registryIDs) <= 0 {
+ if len(registryIDs) > 0 {
cfg.Service.RegistryIDs = registryIDs
}
}
@@ -635,7 +635,7 @@ func WithFilter(filter string) ServiceOption {
// todo(DMwangnima): think about a more ideal configuration style
func WithProtocolIDs(protocolIDs []string) ServiceOption {
return func(cfg *ServiceOptions) {
- if len(protocolIDs) <= 0 {
+ if len(protocolIDs) > 0 {
cfg.Service.ProtocolIDs = protocolIDs
}
}
diff --git a/server/options_test.go b/server/options_test.go
index e0005a4dc..ae52290a6 100644
--- a/server/options_test.go
+++ b/server/options_test.go
@@ -614,7 +614,7 @@ func TestWithRegistryIDs(t *testing.T) {
registryIDs := []string{"registry1"}
opt := WithRegistryIDs(registryIDs)
opt(opts)
- assert.NotEqual(t, registryIDs, opts.Service.RegistryIDs)
+ assert.Equal(t, registryIDs, opts.Service.RegistryIDs)
}
// Test WithFilter
@@ -1060,5 +1060,5 @@ func TestWithProtocolIDs(t *testing.T) {
protocolIDs := []string{"dubbo"}
opt := WithProtocolIDs(protocolIDs)
opt(opts)
- assert.NotEqual(t, protocolIDs, opts.Service.ProtocolIDs)
+ assert.Equal(t, protocolIDs, opts.Service.ProtocolIDs)
}