diff --git a/pkg/common/common.go b/pkg/common/common.go index 284baa04e3866..deb29f97a70db 100644 --- a/pkg/common/common.go +++ b/pkg/common/common.go @@ -23,6 +23,7 @@ import ( "strings" "github.com/cockroachdb/errors" + "github.com/samber/lo" "github.com/milvus-io/milvus-proto/go-api/v2/commonpb" "github.com/milvus-io/milvus-proto/go-api/v2/schemapb" @@ -286,7 +287,7 @@ func DatabaseLevelResourceGroups(kvs []*commonpb.KeyValuePair) ([]string, error) return nil, invalidPropValue } - return rgs, nil + return lo.Map(rgs, func(rg string, _ int) string { return strings.TrimSpace(rg) }), nil } } @@ -321,7 +322,7 @@ func CollectionLevelResourceGroups(kvs []*commonpb.KeyValuePair) ([]string, erro return nil, invalidPropValue } - return rgs, nil + return lo.Map(rgs, func(rg string, _ int) string { return strings.TrimSpace(rg) }), nil } } diff --git a/pkg/util/paramtable/param_item.go b/pkg/util/paramtable/param_item.go index 92e0fcc5bff83..1b25d0095785d 100644 --- a/pkg/util/paramtable/param_item.go +++ b/pkg/util/paramtable/param_item.go @@ -22,6 +22,7 @@ import ( "strings" "time" + "github.com/samber/lo" "go.uber.org/atomic" "github.com/milvus-io/milvus/pkg/config" @@ -335,7 +336,8 @@ func getAsStrings(v string) []string { return []string{} } return getAndConvert(v, func(value string) ([]string, error) { - return strings.Split(value, ","), nil + ret := strings.Split(value, ",") + return lo.Map(ret, func(rg string, _ int) string { return strings.TrimSpace(rg) }), nil }, []string{}) }