@@ -63,7 +63,7 @@ Make sure to defer a call to `Disconnect` after instantiating your client:
6363
6464``` go
6565defer func () {
66- if err = client.Disconnect (ctx); err != nil {
66+ if err : = client.Disconnect (ctx); err != nil {
6767 panic (err)
6868 }
6969}()
@@ -75,7 +75,7 @@ Calling `Connect` does not block for server discovery. If you wish to know if a
7575use the ` Ping ` method:
7676
7777``` go
78- ctx, cancel = context.WithTimeout (context.Background (), 2 *time.Second )
78+ ctx , cancel : = context.WithTimeout (context.Background (), 2 *time.Second )
7979defer cancel ()
8080
8181_ = client.Ping (ctx, readpref.Primary ())
@@ -90,7 +90,7 @@ collection := client.Database("testing").Collection("numbers")
9090The ` Collection ` instance can then be used to insert documents:
9191
9292``` go
93- ctx, cancel = context.WithTimeout (context.Background (), 5 *time.Second )
93+ ctx , cancel : = context.WithTimeout (context.Background (), 5 *time.Second )
9494defer cancel ()
9595
9696res , _ := collection.InsertOne (ctx, bson.D {{" name" , " pi" }, {" value" , 3.14159 }})
@@ -117,7 +117,7 @@ import (
117117Several query methods return a cursor, which can be used like this:
118118
119119``` go
120- ctx, cancel = context.WithTimeout (context.Background (), 30 *time.Second )
120+ ctx , cancel : = context.WithTimeout (context.Background (), 30 *time.Second )
121121defer cancel ()
122122
123123cur , err := collection.Find (ctx, bson.D {})
@@ -148,10 +148,10 @@ var result struct {
148148}
149149
150150filter := bson.D {{" name" , " pi" }}
151- ctx, cancel = context.WithTimeout (context.Background (), 5 *time.Second )
151+ ctx , cancel : = context.WithTimeout (context.Background (), 5 *time.Second )
152152defer cancel ()
153153
154- err = collection.FindOne (ctx, filter).Decode (&result)
154+ err : = collection.FindOne (ctx, filter).Decode (&result)
155155if errors.Is (err, mongo.ErrNoDocuments ) {
156156 // Do something when no record was found
157157} else if err != nil {
0 commit comments