From 39d5d3d89b2be33a5c1048a6910f279aa95c8938 Mon Sep 17 00:00:00 2001 From: luhaoling <2198702716@qq.com> Date: Mon, 4 Mar 2024 11:10:10 +0800 Subject: [PATCH] fix: changge the string ping format --- pkg/common/db/unrelation/mongo.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pkg/common/db/unrelation/mongo.go b/pkg/common/db/unrelation/mongo.go index 8e2403b64..dc00b08a3 100644 --- a/pkg/common/db/unrelation/mongo.go +++ b/pkg/common/db/unrelation/mongo.go @@ -104,12 +104,11 @@ func buildMongoURI(config *config.GlobalConfig) string { maxPoolSize = fmt.Sprint(config.Mongo.MaxPoolSize) } - uriFormat := "mongodb://%s/%s?maxPoolSize=%s" + uriFormat := fmt.Sprintf("mongodb://%s/%s?maxPoolSize=%s", address, database, maxPoolSize) if username != "" && password != "" { - uriFormat = "mongodb://%s:%s@%s/%s?maxPoolSize=%s" - return fmt.Sprintf(uriFormat, username, password, address, database, maxPoolSize) + return fmt.Sprintf("mongodb://%s:%s@%s/%s?maxPoolSize=%s", username, password, address, database, maxPoolSize) } - return fmt.Sprintf(uriFormat, address, database, maxPoolSize) + return uriFormat } func shouldRetry(err error) bool {