From c5ba1956b0349ef2759323b0453e661321df93e8 Mon Sep 17 00:00:00 2001 From: chao <48119764+withchao@users.noreply.github.com> Date: Tue, 5 Mar 2024 18:11:59 +0800 Subject: [PATCH] fix: ptr (#433) --- pkg/common/dbconn/mongo.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/pkg/common/dbconn/mongo.go b/pkg/common/dbconn/mongo.go index 5f5493d2..fd6ab9a8 100644 --- a/pkg/common/dbconn/mongo.go +++ b/pkg/common/dbconn/mongo.go @@ -50,8 +50,8 @@ func buildMongoURI() string { return uri } - if *config.Config.Mongo.Uri != "" { - return *config.Config.Mongo.Uri + if config.Config.Mongo.Uri != "" { + return config.Config.Mongo.Uri } username := os.Getenv("MONGO_OPENIM_USERNAME") @@ -62,21 +62,21 @@ func buildMongoURI() string { maxPoolSize := os.Getenv("MONGO_MAX_POOL_SIZE") if username == "" { - username = *config.Config.Mongo.Username + username = config.Config.Mongo.Username } if password == "" { - password = *config.Config.Mongo.Password + password = config.Config.Mongo.Password } if address == "" { - address = strings.Join(*config.Config.Mongo.Address, ",") + address = strings.Join(config.Config.Mongo.Address, ",") } else if port != "" { address = fmt.Sprintf("%s:%s", address, port) } if database == "" { - database = *config.Config.Mongo.Database + database = config.Config.Mongo.Database } if maxPoolSize == "" { - maxPoolSize = fmt.Sprint(*config.Config.Mongo.MaxPoolSize) + maxPoolSize = fmt.Sprint(config.Config.Mongo.MaxPoolSize) } if username != "" && password != "" { @@ -86,7 +86,7 @@ func buildMongoURI() string { } func buildMongoDatabase() string { - return *config.Config.Mongo.Database + return config.Config.Mongo.Database } func shouldRetry(err error) bool {