From 0458fc56a8730b60cd764ac77b18c50fdbf52677 Mon Sep 17 00:00:00 2001 From: NiteshSingh17 <79739154+NiteshSingh17@users.noreply.github.com> Date: Wed, 20 Aug 2025 08:29:27 +0530 Subject: [PATCH 1/3] Update README.md --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 6fab3db04d..2e89a9ff12 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ Make sure to defer a call to `Disconnect` after instantiating your client: ```go defer func() { - if err = client.Disconnect(ctx); err != nil { + if err := client.Disconnect(ctx); err != nil { panic(err) } }() @@ -75,10 +75,10 @@ Calling `Connect` does not block for server discovery. If you wish to know if a use the `Ping` method: ```go -ctx, cancel = context.WithTimeout(context.Background(), 2*time.Second) +ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() -_ = client.Ping(ctx, readpref.Primary()) +_ := client.Ping(ctx, readpref.Primary()) ``` To insert a document into a collection, first retrieve a `Database` and then `Collection` instance from the `Client`: @@ -90,7 +90,7 @@ collection := client.Database("testing").Collection("numbers") The `Collection` instance can then be used to insert documents: ```go -ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) +ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() res, _ := collection.InsertOne(ctx, bson.D{{"name", "pi"}, {"value", 3.14159}}) @@ -117,7 +117,7 @@ import ( Several query methods return a cursor, which can be used like this: ```go -ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second) +ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second) defer cancel() cur, err := collection.Find(ctx, bson.D{}) @@ -148,10 +148,10 @@ var result struct { } filter := bson.D{{"name", "pi"}} -ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second) +ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() -err = collection.FindOne(ctx, filter).Decode(&result) +err := collection.FindOne(ctx, filter).Decode(&result) if errors.Is(err, mongo.ErrNoDocuments) { // Do something when no record was found } else if err != nil { From 084059828fd8329ce11dd6c1394e659cab2fd6f2 Mon Sep 17 00:00:00 2001 From: NiteshSingh17 <79739154+NiteshSingh17@users.noreply.github.com> Date: Thu, 21 Aug 2025 20:17:16 +0530 Subject: [PATCH 2/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2e89a9ff12..4b490b9bfe 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ use the `Ping` method: ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() -_ := client.Ping(ctx, readpref.Primary()) +client.Ping(ctx, readpref.Primary()) ``` To insert a document into a collection, first retrieve a `Database` and then `Collection` instance from the `Client`: From 8ee0162d49a9cca4bc9020779791eec79bdf72b1 Mon Sep 17 00:00:00 2001 From: NiteshSingh17 <79739154+NiteshSingh17@users.noreply.github.com> Date: Fri, 22 Aug 2025 21:40:36 +0530 Subject: [PATCH 3/3] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b490b9bfe..7e497bf590 100644 --- a/README.md +++ b/README.md @@ -78,7 +78,7 @@ use the `Ping` method: ctx, cancel := context.WithTimeout(context.Background(), 2*time.Second) defer cancel() -client.Ping(ctx, readpref.Primary()) +_ = client.Ping(ctx, readpref.Primary()) ``` To insert a document into a collection, first retrieve a `Database` and then `Collection` instance from the `Client`: