Skip to content

Commit

Permalink
fix: ptr (#433)
Browse files Browse the repository at this point in the history
  • Loading branch information
withchao authored Mar 5, 2024
1 parent 81f7148 commit c5ba195
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions pkg/common/dbconn/mongo.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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 != "" {
Expand All @@ -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 {
Expand Down

0 comments on commit c5ba195

Please sign in to comment.