Fix invalid local ip and aloow setting password in main.go

This commit is contained in:
Late Night Defender 2024-05-27 17:12:31 +07:00
parent b3751856af
commit 5982888cb1

View file

@ -23,7 +23,8 @@ func initReplMongo() {
defer cancel()
// Create a new replica set client
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://sasha:12345@localhost:30000/?directConnection=true"))
uri := fmt.Sprintf("mongodb://%s:%s@localhost:30000/?directConnection=true", mongoInitdbRootUsername, mongoInitdbRootPassword)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
if err != nil {
panic(err)
}
@ -34,7 +35,7 @@ func initReplMongo() {
for i := 0; i < numberOfContainers; i++ {
members[i] = bson.M{
"_id": i,
"host": fmt.Sprintf("%s:%d", string(ips[0]), 30000+i),
"host": fmt.Sprintf("%s:%d", ips[0], 30000+i),
}
}
@ -59,7 +60,8 @@ func initReplMongo() {
defer cancel()
// Create a new replica set client
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://sasha:12345@localhost:30000/?directConnection=true"))
uri := fmt.Sprintf("mongodb://%s:%s@localhost:30000/?directConnection=true", mongoInitdbRootUsername, mongoInitdbRootPassword)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(uri))
if err != nil {
panic(err)
}