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 {