From c1e98e41ded2807b1fe9312bf8b42f249f91923d Mon Sep 17 00:00:00 2001 From: Casper-Mars <50834595+Casper-Mars@users.noreply.github.com> Date: Mon, 21 Feb 2022 18:16:56 +0800 Subject: [PATCH] fix(config/consul):Config from consul skip empty key (#1830) * feat(config/consul):skip empty key * feat(config/consul):delete empty blank --- contrib/config/consul/config.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/config/consul/config.go b/contrib/config/consul/config.go index 8025ec967..afdf91323 100644 --- a/contrib/config/consul/config.go +++ b/contrib/config/consul/config.go @@ -18,7 +18,7 @@ type options struct { path string } -// WithContext with registry context. +// WithContext with registry context. func WithContext(ctx context.Context) Option { return Option(func(o *options) { o.ctx = ctx @@ -71,6 +71,9 @@ func (s *source) Load() ([]*config.KeyValue, error) { kvs := make([]*config.KeyValue, 0) for _, item := range kv { k := strings.TrimPrefix(item.Key, pathPrefix) + if k == "" { + continue + } kvs = append(kvs, &config.KeyValue{ Key: k, Value: item.Value,