diff --git a/contrib/registry/zookeeper/zookeeper_discovery.go b/contrib/registry/zookeeper/zookeeper_discovery.go index c930a1ce3..53eee5288 100644 --- a/contrib/registry/zookeeper/zookeeper_discovery.go +++ b/contrib/registry/zookeeper/zookeeper_discovery.go @@ -19,7 +19,7 @@ import ( // Search searches and returns services with specified condition. func (r *Registry) Search(_ context.Context, in gsvc.SearchInput) ([]gsvc.Service, error) { - prefix := strings.TrimPrefix(strings.ReplaceAll(in.Prefix, "/", "-"), "-") + prefix := strings.Trim(strings.ReplaceAll(in.Prefix, "/", "-"), "-") instances, err, _ := r.group.Do(prefix, func() (interface{}, error) { serviceNamePath := path.Join(r.opts.namespace, prefix) servicesID, _, err := r.conn.Children(serviceNamePath) diff --git a/contrib/registry/zookeeper/zookeeper_registrar.go b/contrib/registry/zookeeper/zookeeper_registrar.go index a69060666..5b8a01817 100644 --- a/contrib/registry/zookeeper/zookeeper_registrar.go +++ b/contrib/registry/zookeeper/zookeeper_registrar.go @@ -31,7 +31,7 @@ func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Servi r.opts.namespace, ) } - prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-") + prefix := strings.Trim(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-") servicePrefixPath := path.Join(r.opts.namespace, prefix) if err = r.ensureName(servicePrefixPath, []byte(""), 0); err != nil { return service, gerror.Wrapf(