The Go driver for MongoDB

Overview

docs docs

MongoDB Go Driver

The MongoDB supported driver for Go.



Requirements

  • Go 1.10 or higher. We aim to support the latest supported versions of go.
  • MongoDB 2.6 and higher.

Installation

The recommended way to get started using the MongoDB Go driver is by using go modules to install the dependency in your project. This can be done either by importing packages from go.mongodb.org/mongo-driver and having the build step install the dependency or by explicitly running

go get go.mongodb.org/mongo-driver/mongo

When using a version of Go that does not support modules, the driver can be installed using dep by running

dep ensure -add "go.mongodb.org/mongo-driver/mongo"

Usage

To get started with the driver, import the mongo package and create a mongo.Client with the Connect function:

import (
    "go.mongodb.org/mongo-driver/mongo"
    "go.mongodb.org/mongo-driver/mongo/options"
    "go.mongodb.org/mongo-driver/mongo/readpref"
)

ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://localhost:27017"))

Make sure to defer a call to Disconnect after instantiating your client:

defer func() {
    if err = client.Disconnect(ctx); err != nil {
        panic(err)
    }
}()

For more advanced configuration and authentication, see the documentation for mongo.Connect.

Calling Connect does not block for server discovery. If you wish to know if a MongoDB server has been found and connected to, use the Ping method:

ctx, cancel = context.WithTimeout(context.Background(), 2*time.Second)
defer cancel()
err = client.Ping(ctx, readpref.Primary())

To insert a document into a collection, first retrieve a Database and then Collection instance from the Client:

collection := client.Database("testing").Collection("numbers")

The Collection instance can then be used to insert documents:

ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
res, err := collection.InsertOne(ctx, bson.D{{"name", "pi"}, {"value", 3.14159}})
id := res.InsertedID

To use bson.D, you will need to add "go.mongodb.org/mongo-driver/bson" to your imports.

Your import statement should now look like this:

import (
    "go.mongodb.org/mongo-driver/bson"
    "go.mongodb.org/mongo-driver/mongo"
    "go.mongodb.org/mongo-driver/mongo/options"
    "go.mongodb.org/mongo-driver/mongo/readpref"
)

Several query methods return a cursor, which can be used like this:

ctx, cancel = context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
cur, err := collection.Find(ctx, bson.D{})
if err != nil { log.Fatal(err) }
defer cur.Close(ctx)
for cur.Next(ctx) {
   var result bson.D
   err := cur.Decode(&result)
   if err != nil { log.Fatal(err) }
   // do something with result....
}
if err := cur.Err(); err != nil {
  log.Fatal(err)
}

For methods that return a single item, a SingleResult instance is returned:

var result struct {
    Value float64
}
filter := bson.D{{"name", "pi"}}
ctx, cancel = context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
err = collection.FindOne(ctx, filter).Decode(&result)
if err != nil {
    log.Fatal(err)
}
// Do something with result...

Additional examples and documentation can be found under the examples directory and on the MongoDB Documentation website.


Feedback

For help with the driver, please post in the MongoDB Community Forums.

New features and bugs can be reported on jira: https://jira.mongodb.org/browse/GODRIVER


Testing / Development

The driver tests can be run against several database configurations. The most simple configuration is a standalone mongod with no auth, no ssl, and no compression. To run these basic driver tests, make sure a standalone MongoDB server instance is running at localhost:27017. To run the tests, you can run make (on Windows, run nmake). This will run coverage, run go-lint, run go-vet, and build the examples.

Testing Different Topologies

To test a replica set or sharded cluster, set MONGODB_URI="<connection-string>" for the make command. For example, for a local replica set named rs1 comprised of three nodes on ports 27017, 27018, and 27019:

MONGODB_URI="mongodb://localhost:27017,localhost:27018,localhost:27018/?replicaSet=rs1" make

Testing Auth and TLS

To test authentication and TLS, first set up a MongoDB cluster with auth and TLS configured. Testing authentication requires a user with the root role on the admin database. The Go Driver repository comes with example certificates in the data/certificates directory. These certs can be used for testing. Here is an example command that would run a mongod with TLS correctly configured for tests:

mongod \
--auth \
--tlsMode requireTLS \
--tlsCertificateKeyFile $(pwd)/data/certificates/server.pem \
--tlsCAFile $(pwd)/data/certificates/ca.pem \
--tlsAllowInvalidCertificates

To run the tests with make, set MONGO_GO_DRIVER_CA_FILE to the location of the CA file used by the database, set MONGODB_URI to the connection string of the server, set AUTH=auth, and set SSL=ssl. For example:

AUTH=auth SSL=ssl MONGO_GO_DRIVER_CA_FILE=$(pwd)/data/certificates/ca.pem  MONGODB_URI="mongodb://user:[email protected]:27017/?authSource=admin" make

Notes:

  • The --tlsAllowInvalidCertificates flag is required on the server for the test suite to work correctly.
  • The test suite requires the auth database to be set with ?authSource=admin, not /admin.

Testing Compression

The MongoDB Go Driver supports wire protocol compression using Snappy, zLib, or zstd. To run tests with wire protocol compression, set MONGO_GO_DRIVER_COMPRESSOR to snappy, zlib, or zstd. For example:

MONGO_GO_DRIVER_COMPRESSOR=snappy make

Ensure the --networkMessageCompressors flag on mongod or mongos includes zlib if testing zLib compression.


Contribution

Check out the project page for tickets that need completing. See our contribution guidelines for details.


Continuous Integration

Commits to master are run automatically on evergreen.


Thanks and Acknowledgement

@ashleymcnamara - Mongo Gopher Artwork


License

The MongoDB Go Driver is licensed under the Apache License.

Comments
  • GODRIVER-567 Returned time.Time instead of int64 when decoding an IsoDate

    GODRIVER-567 Returned time.Time instead of int64 when decoding an IsoDate

    Hi, the value returned in case of null time is an empty time.Time struct, when teh time is not null, however, an int64 is returned, which makes no sense and prevents from decoding an ISODate into time.Time

    There was no test for a non empty Time value, so I added it.

    This is for teh JIRA ticket GODRIVER-567

    opened by delioda79 12
  • Fix bsoncore overflow

    Fix bsoncore overflow

    Hello, we were fuzzing one of our libraries that depend on bsonx and found following panics

    panic: runtime error: index out of range [-1]
    
    goroutine 1 [running]:
    go.mongodb.org/mongo-driver/x/bsonx/bsoncore.Document.Validate(0x4381000, 0x4, 0x4, 0x12dad00, 0xc0000102c0)
    	XXXX/mongo-driver/x/bsonx/bsoncore/document.go:373 +0x6e3
    go.mongodb.org/mongo-driver/x/bsonx.(*Doc).UnmarshalBSON(0xc0000cbe08, 0x4381000, 0x4, 0x4, 0xc0000cbe08, 0x99c4e6fa)
    	XXXX/mongo-driver/x/bsonx/document.go:225 +0xb6
    go.mongodb.org/mongo-driver/x/bsonx.ReadDoc(0x4381000, 0x4, 0x4, 0xc0000cbe70, 0x1076066, 0x5dcdd198, 0xdc8138, 0x133fa99c4e6fa)
    
    XXXXXXXXXXXXXXXX
    
    exit status 2
    
    ----------
    
    panic: runtime error: slice bounds out of range [:-2147483643]
    
    goroutine 1 [running]:
    go.mongodb.org/mongo-driver/x/bsonx/bsoncore.ReadElement(0x4221004, 0x6, 0x6, 0xc000000006, 0x4221004, 0x6, 0x6, 0x1, 0x9, 0x4221004)
    	XXXX/mongo-driver/x/bsonx/bsoncore/bsoncore.go:126 +0x3c8
    go.mongodb.org/mongo-driver/x/bsonx/bsoncore.Document.Validate(0x4221000, 0xa, 0xa, 0x12dad20, 0xc0000c20a0)
    	XXXX/mongo-driver/x/bsonx/bsoncore/document.go:381 +0x208
    go.mongodb.org/mongo-driver/x/bsonx.(*Doc).UnmarshalBSON(0xc0000cbe08, 0x4221000, 0xa, 0xa, 0xc0000cbe08, 0x87888daf)
    	XXXX/mongo-driver/x/bsonx/document.go:225 +0xb6
    
    XXXXXXXXXXXXXXXX
    
    exit status 2
    

    This PR should fix that.

    opened by tvi 9
  • Add go module support

    Add go module support

    It would be really useful to have support for go modules. This PR just adds the go.mod and go.sum needed for modules support. Tagging commit 1c3b9b9a41eecdf056560e07b68e6407b8d598c3 as v1.0.0 is also required (but can't be done via a PR).

    opened by ASankaran 9
  • GODRIVER-2233 Bump packr/v2 dependency version to avoid vulnerability

    GODRIVER-2233 Bump packr/v2 dependency version to avoid vulnerability

    This PR simply bumps up the version of the github.com/gobuffalo/packr/v2 dependency to be version 2.8.1.

    This change is being made to address a security vulnerability that has been reported by Snyk: https://security.snyk.io/vuln/SNYK-GOLANG-GITHUBCOMGOBUFFALOPACKRV2-1920670 The remediation for this vulnerability is to use version 2.3.2 or higher of the packr package.

    opened by padamstx 8
  • GODRIVER-2161 Add NewSingleResultFromDocument and NewCursorFromDocuments functions

    GODRIVER-2161 Add NewSingleResultFromDocument and NewCursorFromDocuments functions

    GODRIVER-2161

    Adds a new SingleResult constructor NewSingleResultFromDocument that makes a SingleResult with an underlying Cursor pre-loaded with a singleton slice of documents ([]interface{}{document}) as the first batch. Adds a new Cursor construct NewCursorFromDocuments that makes a Cursor pre-loaded with a slice of documents ([]interface{}) as the first batch. These new functions can be used to mock server responses to read operations (e.g. Find, FindOne, Aggregate). Adds associated unit and integration tests.

    opened by benjirewis 7
  • Fix panic on ARM, 386, and 32-bit MIPS by aligne fileds used by atomic package

    Fix panic on ARM, 386, and 32-bit MIPS by aligne fileds used by atomic package

    When I tried to use my program on ARM I got panic:

    (...)
    panic: unaligned 64-bit atomic operation [recovered]
            panic: unaligned 64-bit atomic operation
    
    goroutine 1 [running]:
    github.com/alecthomas/kong.catch(0x2cb1f58)
            /home/sr/go/pkg/mod/github.com/alecthomas/[email protected]/kong.go:407 +0xa8
    panic(0x6b9540, 0x8b0528)
            /usr/lib/go/src/runtime/panic.go:965 +0x174
    runtime/internal/atomic.panicUnaligned()
            /usr/lib/go/src/runtime/internal/atomic/unaligned.go:8 +0x24
    runtime/internal/atomic.Xadd64(0x2c77b14, 0x1, 0x0, 0x7, 0xc)
            /usr/lib/go/src/runtime/internal/atomic/asm_arm.s:233 +0x14
    go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).makeNewConnection(0x2c77ae0, 0x2d62c01, 0x0, 0x1, 0x0, 0x0)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:287 +0x94
    go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*pool).get(0x2c77ae0, 0x8bc73c, 0x2cf99c0, 0x0, 0x0, 0x2cc8988)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/pool.go:440 +0x3b0
    go.mongodb.org/mongo-driver/x/mongo/driver/topology.(*Server).Connection(0x2d96f30, 0x8bc73c, 0x2cf99c0, 0x0, 0x0, 0x0, 0x0)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/topology/server.go:268 +0x5c
    go.mongodb.org/mongo-driver/x/mongo/driver.Operation.getServerAndConnection(0x2dae628, 0x752d82, 0xb, 0x8ba99c, 0x2d87580, 0x2dae630, 0x8b84d4, 0x2db3680, 0x0, 0x0, ...)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation.go:246 +0x94
    go.mongodb.org/mongo-driver/x/mongo/driver.Operation.Execute(0x2dae628, 0x752d82, 0xb, 0x8ba99c, 0x2d87580, 0x2dae630, 0x8b84d4, 0x2db3680, 0x0, 0x0, ...)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation.go:301 +0x80
    go.mongodb.org/mongo-driver/x/mongo/driver/operation.(*Insert).Execute(0x2d9aea0, 0x8bc73c, 0x2cf99c0, 0x2dae620, 0x9f3c141e)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/x/mongo/driver/operation/insert.go:109 +0x1a4
    go.mongodb.org/mongo-driver/mongo.(*Collection).insert(0x2d83440, 0x8bc73c, 0x2cf99c0, 0x2cb1bf4, 0x1, 0x1, 0x2cb1be8, 0x1, 0x1, 0x0, ...)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/mongo/collection.go:297 +0x54c
    go.mongodb.org/mongo-driver/mongo.(*Collection).InsertOne(0x2d83440, 0x8bc73c, 0x2cf99c0, 0x690128, 0x2d9ae40, 0x0, 0x0, 0x0, 0xc0425a05, 0x82bfeb58, ...)
            /home/sr/go/pkg/mod/go.mongodb.org/[email protected]/mongo/collection.go:336 +0xd4
     (...)
    

    The atomic package has a bug section with this note:

    On ARM, 386, and 32-bit MIPS, it is the caller's responsibility to arrange for 64-bit alignment of 64-bit words accessed atomically. The first word in a variable or in an allocated struct, array, or slice can be relied upon to be 64-bit aligned.

    I have tested it with my program after change (on arm target) and it worked.

    opened by xoac 7
  • GODRIVER-1147 Add an API to create collections

    GODRIVER-1147 Add an API to create collections

    I ended up adding separate APIs for creating collections and views even though both use the same create command under the hood because the command doesn't have great separation of concerns. A lot of the server options (e.g. capped, valdiator, etc) do not apply when creating a view, so separate APIs made sense to me. This is also in line with what mgo did. In scope of this ticket, I also added embedded documentation examples and switched the integration testing library to use the new APIs rather than RunCommand to create collections.

    The main open question is whether or not we should include options like AutoIndexID, which was deprecated in 3.2 and removed in 4.0 for all databases besides "local". I included it becuase we still support 2.6 and 3.0, even though those have been EOLed.

    opened by divjotarora 7
  • GODRIVER-693: Fix error on decoding using a change stream cursor on a database

    GODRIVER-693: Fix error on decoding using a change stream cursor on a database

    On opening a change stream cursor for any database, whenever the cursor is used to decode, it panics on runtime.

    Generate the case using: https://gist.github.com/Shivam010/bf057e4fcf65954c62751b0e544bbd1e

    GODRIVER-693

    opened by Shivam010 6
  • Add comment to DateTime constructor

    Add comment to DateTime constructor

    Also I would like to create constructor from time.Time, if you allow me. Like that:

    // Time creates a datetime element with the given key and value.
    func (c ElementConstructor) Time(key string, time time.Time) *Element {
    	return c.DateTime(key, time.Unix() * 1000)
    }
    
    opened by Hixon10 6
  • Feature - Transaction state in session

    Feature - Transaction state in session

    Now the only possible way to check if transaction in progress (for Session interface) is to call StartTransaction, AbortTransaction or CommitTransaction method and handle errors. It is unacceptable for obvious reasons. I've added TransactionState method to Session interface.

    Use case: choosing read preference for collection method call depending on transaction status.

    opened by Gleb-ho 5
  • GODRIVER-2677 Limit the maximum number of items in pool.

    GODRIVER-2677 Limit the maximum number of items in pool.

    GODRIVER-2677

    Summary

    Reduce the memory consumption by setting a maximum number of items in the byte slice pool.

    Background & Motivation

    I limited 512 slices in the pool. Get() allocates directly from the system when it reaches the limit. So the size of the pool shall not be bigger than 16MB * 512 ~= 8GB in theory considering the ticket indicates ~20GB of memory consumption. I did not reset the capacity of returned byte slice because it would cause more allocations.

    The benchstat from benchmark/operation_test.go:

    name                           old time/op    new time/op    delta
    ClientWrite/not_compressed-10    2.00ms ± 9%    1.96ms ±10%     ~     (p=0.853 n=10+10)
    ClientWrite/snappy-10            2.10ms ± 8%    1.88ms ± 6%  -10.48%  (p=0.000 n=10+9)
    ClientWrite/zlib-10              2.04ms ±19%    1.84ms ±12%   -9.83%  (p=0.011 n=10+10)
    ClientWrite/zstd-10              2.02ms ±12%    1.91ms ±12%     ~     (p=0.105 n=10+10)
    
    name                           old alloc/op   new alloc/op   delta
    ClientWrite/not_compressed-10    27.7kB ± 2%    27.7kB ± 1%     ~     (p=0.579 n=10+10)
    ClientWrite/snappy-10            41.4kB ± 2%    51.4kB ± 1%  +24.19%  (p=0.000 n=10+10)
    ClientWrite/zlib-10               906kB ± 0%     914kB ± 0%   +0.81%  (p=0.000 n=10+10)
    ClientWrite/zstd-10              67.0kB ± 0%    76.7kB ± 0%  +14.49%  (p=0.000 n=10+10)
    
    name                           old allocs/op  new allocs/op  delta
    ClientWrite/not_compressed-10      79.0 ± 0%      81.5 ± 1%   +3.16%  (p=0.000 n=8+10)
    ClientWrite/snappy-10              82.0 ± 0%      88.6 ± 1%   +8.05%  (p=0.000 n=8+10)
    ClientWrite/zlib-10                 122 ± 1%       128 ± 1%   +4.99%  (p=0.000 n=10+10)
    ClientWrite/zstd-10                 183 ± 0%       188 ± 0%   +2.90%  (p=0.000 n=8+10)
    
    name                          old time/op    new time/op    delta
    ClientRead/not_compressed-10     153µs ±12%     166µs ±11%   +8.26%  (p=0.035 n=10+10)
    ClientRead/snappy-10             149µs ±14%     165µs ± 6%  +10.80%  (p=0.001 n=10+10)
    ClientRead/zlib-10               240µs ± 8%     263µs ± 2%   +9.72%  (p=0.000 n=9+9)
    ClientRead/zstd-10               130µs ± 4%     173µs ± 8%  +32.88%  (p=0.000 n=10+10)
    
    name                          old alloc/op   new alloc/op   delta
    ClientRead/not_compressed-10    29.0kB ± 0%    29.0kB ± 0%     ~     (p=0.171 n=10+10)
    ClientRead/snappy-10            45.7kB ± 0%    46.1kB ± 0%   +0.88%  (p=0.000 n=10+9)
    ClientRead/zlib-10               905kB ± 0%     906kB ± 0%   +0.17%  (p=0.000 n=8+10)
    ClientRead/zstd-10               135kB ± 0%     136kB ± 0%   +0.33%  (p=0.000 n=10+10)
    
    name                          old allocs/op  new allocs/op  delta
    ClientRead/not_compressed-10      83.0 ± 0%      85.0 ± 0%   +2.41%  (p=0.000 n=10+10)
    ClientRead/snappy-10              87.0 ± 0%      90.0 ± 0%   +3.45%  (p=0.000 n=10+10)
    ClientRead/zlib-10                 143 ± 0%       147 ± 0%   +3.08%  (p=0.000 n=9+10)
    ClientRead/zstd-10                 191 ± 0%       194 ± 0%   +1.57%  (p=0.000 n=10+10)
    
    opened by qingyang-hu 0
  • GODRIVER-2658 Better guard against nil pinned connections.

    GODRIVER-2658 Better guard against nil pinned connections.

    GODRIVER-2658

    Summary

    Adds ServerConnectionID() to topology.Connection to avoid panics when that method is called against &topology.Connection{}. Adds IsNil() to the driver.Connection interface to more robustly check for nil connections in driver.Connection implementations that wrap an underlying connection that may be nil. Uses the new IsNil() method to better check nilness when potentially returning pinned connections in getServerAndConnection().

    Background & Motivation

    Users are occasionally seeing panics from the ServerConnectionID() here. The driver was panic'ing because topology.Connection did not implement a ServerConnectionID() method that guarded against the underlying connection being nil. It is odd that the driver returns &topology.Connection{} from getServerAndConnection, but since this issue is only reported against serverless instances, we can just add a check to getServerAndConnection to not return the pinned connection (and continue to regular connection check out) when the PinnedConnection isn't nil but its underlying connection is (as is the case with &topology.Connection{}).

    opened by benjirewis 1
  • Add POC for reply callback

    Add POC for reply callback

    Summary

    Add a "ReplyCallback" field to the CommandMonitor struct to give users the option of altering the response of a request before it is propagated to the CommandSucceeded event.

    A use case for this would look something like the following:

    package main
    
    import (
    	"context"
    	"log"
    
    	"go.mongodb.org/mongo-driver/bson"
    	"go.mongodb.org/mongo-driver/event"
    	"go.mongodb.org/mongo-driver/mongo"
    	"go.mongodb.org/mongo-driver/mongo/options"
    	"go.mongodb.org/mongo-driver/x/bsonx/bsoncore"
    )
    
    func main() {
    	cmdMonitor := new(event.CommandMonitor)
    
    	cmdMonitor.ReplyCallback = func(ctx context.Context, rsp *bsoncore.Document) bson.Raw { 
                     return nil 
            }
    	cmdMonitor.Succeeded = func(context.Context, *event.CommandSucceededEvent) {}
    
    	ctx := context.Background()
    
    	clientOptions := options.Client().ApplyURI("mongodb://localhost:27017").SetMonitor(cmdMonitor)
    	client, err := mongo.Connect(ctx, clientOptions)
    	if err != nil {
    		log.Fatal(err)
    	}
    
    	if err = client.Ping(ctx, nil); err != nil {
    		log.Fatal(err)
    	}
    }
    

    Background & Motivation

    A user is suggesting adding a "Finished" event to the CommandMonitor in PR #1106. The user's solution may be the best solution, this PR is to explore alternatives.

    opened by prestonvasquez 0
  • GODRIVER-2674 use time.Duration instead of durationNanos

    GODRIVER-2674 use time.Duration instead of durationNanos

    Same as #1105

    OK make fmt
    OK make lint
    make test: go.mongodb.org/mongo-driver/mongo/integration/unified: no such command: 'configureFailPoint'
    (make test fails on master with same result)
    make test-race: same result as make test
    
    opened by jtagcat 0
  • add CommandFinishedEvent to monitor without response copies

    add CommandFinishedEvent to monitor without response copies

    Summary

    Add new event for monitoring to subscribe to operation finishes without heavy info about failure or success

    Background & Motivation

    In our busy service publishFinishedEvent func does ~100GB of allocations in 2 hours and possesses the 4th place by allocations. AFAIU these allocations are rooted to the copies of server responses which we do not use. How about allowing to subscribe to operation finish event without the details about success or failure?

    image

    opened by isopov 1
Releases(v1.11.1)
  • v1.11.1(Dec 8, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.11.1 of the official Go driver.

    Release Notes

    This release contains a bug fix for heartbeat buildup with streaming protocol when the Go driver process is paused in an FAAS environment (e.g. AWS Lambda). This release also includes a bug fix for handling sequential "NoWritesPerformed" labeled operation errors, in that they should still return the "previous indefinite error".

    P.S. We want to hear about how Go developers use MongoDB and the MongoDB Go Driver! If you haven't already, please take the 2022 MongoDB Go Developer Survey.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.5(Dec 6, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.10.5 of the official Go driver.

    Release Notes

    This release contains a bugfix for heartbeat buildup with streaming protocol when the Go driver process is paused in an FAAS environment (e.g. AWS Lambda).


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!


    P.S. We want to hear about how Go developers use MongoDB and the MongoDB Go Driver! If you haven't already, please take the 2022 MongoDB Go Developer Survey.

    Source code(tar.gz)
    Source code(zip)
  • v1.9.4(Dec 6, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.9.4 of the official Go driver.

    Release Notes

    This release contains a bugfix for heartbeat buildup with streaming protocol when the Go driver process is paused in an FAAS environment (e.g. AWS Lambda).


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!


    P.S. We want to hear about how Go developers use MongoDB and the MongoDB Go Driver! If you haven't already, please take the 2022 MongoDB Go Developer Survey.

    Source code(tar.gz)
    Source code(zip)
  • v1.11.0(Nov 3, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.11.0 of the official Go driver.

    Release Notes

    This release improves the Timeout API and behavior, reduces memory allocations when running most operations, and fixes several bugs. It also removes support for some legacy versions of MongoDB and Go. See below for more details.

    Improve Timeout API and Behavior

    Setting Timeout on a mongo.Client to enable a client-level default operation timeout is a feature added in version 1.10.0 of the driver. Various improvements have been made to this API. In particular:

    • If Timeout is set, the driver will now retry as many times as possible before the context's deadline instead of just once. This should improve application resiliency when using Timeout.
    • The mongo.IsTimeout error helper has been extended to catch more timeout errors.
    • New GridFS methods have been added that take contexts instead of using SetReadDeadline and SetWriteDeadline.

    This feature will remain a provisional API while we gather feedback on its design and solidify our specification.

    Reduce Memory Allocations

    Reduce memory allocations in several critical paths in operation execution.

    Fix SRV Polling

    Fix a severe bug in SRV polling which may prevent changes in SRV records from updating the servers that the Go driver attempts to connect to when the MongoDB connection string includes a username and password.

    Remove Support for Legacy MongoDB Versions

    As of this release, the Go driver now requires MongoDB 3.6 or newer.

    Remove Support for Legacy Go Versions

    As of this release, the Go driver now requires Go 1.13 or newer.

    Additional Features and Improvements

    • Improve server-side resource cleanup when using the Cursor.All and Session.WithTransaction functions.
    • Add support for GCP service accounts when using GCP KMS.
    • Allow specifying the SERVICE_HOST Kerberos authentication parameter in the authMechanismProperties connection string option.
    • Improve error message when operations fail due to context cancellation.

    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.9.3(Nov 2, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.9.3 of the official Go driver.

    Release Notes

    This release fixes a severe bug in SRV polling which may prevent changes in SRV records from updating the servers that the Go Driver attempts to connect to when the MongoDB connection string includes a username and password.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.8.6(Nov 2, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.8.6 of the official Go driver.

    Release Notes

    This release fixes a severe bug in SRV polling which may prevent changes in SRV records from updating the servers that the Go Driver attempts to connect to when the MongoDB connection string includes a username and password.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.4(Nov 2, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.10.4 of the official Go driver.

    Release Notes

    This release contains several bugfixes. One of the bugfixes removes a severe bug in SRV polling which may prevent changes in SRV records from updating the servers that the Go Driver attempts to connect to when the MongoDB connection string includes a username and password.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.3(Oct 4, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.10.3 of the official Go driver.

    Release Notes

    This release contains several bugfixes.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.9.2(Oct 4, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.9.2 of the official Go driver.

    Release Notes

    This release contains a bugfix: MinPoolSize can no longer be set to exceed the value of MaxPoolSize.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.2(Sep 6, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.10.2 of the official Go driver.

    Release Notes

    This release stops treating context errors as retryable network errors where possible.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.1(Aug 3, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.10.1 of the official Go driver.

    Release Notes

    This release, along with the libmongocrypt v1.5.2 release, fixes a potential encryption key corruption bug in ClientEncryption.RewrapManyDataKey that can lead to encrypted data corruption when rotating encryption keys backed by GCP or Azure key services.

    This release also removes potentially confusing deprecation warnings added to some existing timeout mechanisms in the v1.10.0 release.

    Fix for potential data corruption when rotating encryption keys

    Fixes a potential encryption key corruption bug in ClientEncryption.RewrapManyDataKey that can lead to encrypted data corruption when rotating encryption keys backed by GCP or Azure key services. See the libmongocrypt v1.5.2 release notes for more details about the bug. ClientEncryption.RewrapManyDataKey will now return an error if the linked version of libmongocrypt is less than 1.5.2.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.0(Jul 14, 2022)

    :warning: Retracted

    This release has been retracted due to a potential encryption key corruption bug in ClientEncryption.RewrapManyDataKey that can lead to encrypted data corruption when rotating encryption keys backed by GCP or Azure key services.

    Please use version 1.10.1 or higher.


    The MongoDB Go Driver Team is pleased to release version 1.10.0 of the official Go driver.

    Release Notes

    This release supports several new features introduced in MongoDB v6.0, including the following notable changes.

    Queryable Encryption Support

    This release includes new options to AutoEncryptionOpts and EncryptOpts to support Queryable Encryption. Queryable Encryption support requires MongoDB server 6.0 or newer, and libmongocrypt 1.5.0 or newer.

    Automatic Encryption Shared Library

    Add support for the new encryption helper, crypt_shared, referred to as the Shared Library. The shared library replacesmongocryptd and does not require spawning a new process.

    Key Management API Operations

    Add ClientEncryption entity operations for Key Management API with the purpose of

    • creating data keys
    • rewrapping data keys
    • deleting data keys
    • adding and removing alternative names to data keys
    • getting data keys

    Warning There is a severe bug when calling RewrapManyDataKey with libmongocrypt versions less than 1.5.2. This bug may result in data corruption. Please use libmongocrypt 1.5.2 or higher when calling RewrapManyDataKey.

    Patch for Decoding Empty Types

    A patch is implemented for defaulting data to either primitive.M or primitive.D when decoding empty types.

    Encoding Atypical Map Key Types

    Allow encoding atypical map key types for data that can unmarshal into a textual representation of itself, i.e. TextMarshaler and TextUnmarshaler.

    Improvement of Full Document Request

    Add the ability to request the full document both before and after an update in Change Stream events.

    PRN and UUID Generation Refactoring

    Refactor the pseudo-random number and UUID generation to improve performance and reduce conflict.

    Reducing memory consumption when compressing wire messages

    Refactor the Zstd compression to reduce memory consumption.

    Provisional API for Timeout

    The new Timeout client option can be used to set a default context timeout for every operation sent through that client. SetTimeout represents unstable, provisional API; the behavior of the driver when a Timeout is specified is subject to change.

    Troubleshooting Documentation

    The Go Driver team will start supporting a docs/common-issues.md file for troubleshooting frequently encountered issues.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.10.0-beta1(Jun 1, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.10.0-beta1 of the official Go driver.

    Release Notes

    This release supports several new features introduced in MongoDB server version 6.0 (Release Candidate).

    Queryable Encryption Support

    This release includes new options to AutoEncryptionOpts and EncryptOpts to support Queryable Encryption. Queryable Encryption support requires MongoDB server 6.0 or newer, and libmongocrypt 1.5.0 or newer.

    Patch for Decoding Empty Types

    A patch is implemented for defaulting data to either primitive.M or primitive.D when decoding empty types.

    Encoding Atypical Map Key Types

    Allow encoding atypical map key types for data that can unmarshal into a textual representation of itself, i.e. TextMarshaler and TextUnmarshaler.

    Improvement of Full Document Request

    Add the ability to request the full document both before and after an update in Change Stream events.

    PRN and UUID Generation Refactoring

    Refactor the pseudo-random number and UUID generation to improve performance and reduce conflict.

    Adding Comment Support for CRUD Operations


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.9.1(May 3, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.9.1 of the official Go driver.

    Release Notes

    This release includes various bug fixes, including fixing the "soft fail" behavior of the OCSP certificate check and correctly handling 32- or 64-bit integers in server responses.


    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver project in the MongoDB JIRA where a list of current issues can be found. Your feedback on the Go driver is greatly appreciated!

    Source code(tar.gz)
    Source code(zip)
  • v1.7.6(Apr 11, 2022)

    The MongoDB Go Driver Team is pleased to release version 1.7.6 of the official Go driver.

    Release Notes

    This release fixes a bug that can corrupt unmarshaled BSON values in specific circumstances.

    For a full list of tickets included in this release, please see the links below:

    Documentation for the Go driver can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Source code(tar.gz)
    Source code(zip)
  • v1.9.0(Apr 6, 2022)

    The MongoDB Go driver team is pleased to release version 1.9.0 of the official Go driver.

    Release Notes

    This release contains improvements to connection pool management, an extended API, and a number of bug fixes.

    Connection storm mitigation

    Previously, the propensity of the driver to inundate a server with new connections during failover events was a particular pain point. This version of the driver contains a number of improvements to mitigate these connection "storms" including:

    • Consider server load during server selection
    • Prevent creating connections to unhealthy servers
    • Re-select a server if that server becomes unhealthy during check-out

    Custom Aggregate and ChangeStream options

    Certain use-cases may require supplying custom options on aggregate commands. These aggregate operations could be on a Database, Collection or for the creation of a ChangeStream. This version of the driver adds new API to specify custom options in these cases:

    Note that all the custom options above must be marshalable into BSON. Users should always prefer using non-custom options where possible.

    Let option for CRUD commands

    This version of the driver adds a Let option to most CRUD command options. Let can be used to specify parameters for use in an aggregate expression context (e.g. "$$var"). Let must be a document mapping parameter names to values that are constant or closed expressions without references to document fields. Note that the Let option can only be used against server version 5.0 or higher. Let has been added to:

    • AggregateOptions
    • BulkWriteOptions
    • DeleteOptions
    • FindOptions
    • FindOneAndDeleteOptions
    • FindOneAndReplaceOptions
    • FindOneAndUpdateOptions
    • ReplaceOptions
    • UpdateOptions

    Cursor and SingleResult constructors

    This version of the driver exposes API to create Cursor and SingleResult instances from BSON document(s). In particular, two new constructor functions have been added: NewCursorFromDocuments and NewSingleResultFromDocument. The supplied document(s) must be marshalable and non-nil. These new functions should allow for the mocking of read operation results (such as Find, FindOne and Aggregate) for use in testing.


    For a full list of tickets included in this release, please see the links below:

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Source code(tar.gz)
    Source code(zip)
  • v1.8.5(Apr 6, 2022)

    The MongoDB Go driver team is pleased to release version 1.8.5 of the official Go driver.

    Release Notes

    This release fixes various bugs, including a bug that could cause duplicate session IDs and a bug that can corrupt unmarshaled BSON values in specific circumstances.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.


    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.8.4(Mar 3, 2022)

    The MongoDB Go driver team is pleased to release version 1.8.4 of the official Go driver.

    This release resolves a bug that prevented an empty readPreferenceTags value in a connection string from acting as a "fail-safe" read preference tag that matches any eligible member (see documentation here).

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.8.3(Feb 1, 2022)

    The MongoDB Go driver team is pleased to release version 1.8.3 of the official Go driver.

    This release contains a bug fix to allow the loading of multiple certs within a single PEM file.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.8.2(Jan 5, 2022)

    The MongoDB Go driver team is pleased to release version 1.8.2 of the official Go driver.

    This release adds the ability to configure the recently added maxConnecting rate limit via the SetMaxConnecting function or the maxConnecting= URI option. The maxConnecting value sets the maximum number of new connections that can be created simultaneously.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.8.1(Dec 8, 2021)

    The MongoDB Go driver team is pleased to release version 1.8.1 of the official Go driver.

    This release contains a bug fix to correct the error type returned by IndexView.CreateMany.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the link below:

    Source code(tar.gz)
    Source code(zip)
  • v1.8.0(Nov 23, 2021)

    The MongoDB Go driver team is pleased to release version 1.8.0 of the official Go driver.

    This release supports additional features introduced in MongoDB version 5.1 and includes a refactor to our connection-pooling logic.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    CSFLE 1.0 KMIP Support

    Supports using KMIP as a KMS provider for client side encryption.

    Example of registering a client with auto-encryption through a KMIP KMS server with TLS.

    // Provide KMS providers map with KMIP endpoint.
    kmipKmsProviderMap := map[string]map[string]interface{}{
            "kmip": {
    	        "endpoint": "IP.of.KMIP.Server",
            },
    }
    
    // Create TLS config with tlsCertificateKeyFile and tlsCAFile.
    tlsConfig := make(map[string]*tls.Config)
    tlsOpts := map[string]interface{}{
            "tlsCertificateKeyFile": "path/to/tls/certfile",
            "tlsCAFile":             "path/to/tls/cafile",
    }
    
    // Build config and handle error.
    kmipConfig, err := options.BuildTLSConfig(tlsOpts)
    if err != nil {
            panic(err)
    }
    tlsConfig["kmip"] = kmipConfig
    
    // Create new client with auto-encryption options.
    aeo := options.AutoEncryption().
            SetKmsProviders(kmipKmsProviderMap).
            SetKeyVaultNamespace("keyvault.datakeys").
            SetTLSConfig(tlsConfig)
    opts := options.Client().ApplyURI("mongodb://localhost:27017").SetAutoEncryptionOptions(aeo)
    client, err := mongo.NewClient(opts)
    if err != nil {
            panic(err)
    }
    

    Oppressive Language Removal

    Following the guidance documented here, we removed all oppressive and unnecessarily gendered language in the Go driver documentation, code, tests, and spec tests.

    Connection Pool Redesign

    The driver connection pool has been redesigned to work better when using low (< 30s) operation Context timeouts and reduce connection churn.

    Behavior changes:

    • New connection creation is timed out at connectTimeoutMS. Previously, new connection creation was done synchronously with an operation and was timed out with the minimum of the operation Context timeout and connectTimeoutMS.
    • At most 2 connections are established at the same time. Previously, the max number of new connections established at the same time was maxPoolSize.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.7.5(Nov 23, 2021)

    The MongoDB Go driver team is pleased to release version 1.7.5 of the official Go driver.

    This release removes an internal code generation tool and its associated dependencies.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.7.4(Nov 3, 2021)

    The MongoDB Go driver team is pleased to release version 1.7.4 of the official Go driver.

    This release contains several bugfixes.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.7.3(Oct 5, 2021)

    The MongoDB Go driver team is pleased to release version 1.7.3 of the official Go driver.

    This release contains several bugfixes.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.7.2(Sep 2, 2021)

    The MongoDB Go driver team is pleased to release version 1.7.2 of the official Go driver.

    This release contains various bug fixes, including:

    • Fix for a data race that can occur between creating and checking out connections when minPoolSize > 0.
    • Filter servers based on localThresholdMS when opening a new ChangeStream.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.6.2(Sep 2, 2021)

    The MongoDB Go driver team is pleased to release version 1.6.2 of the official Go driver.

    This release contains a bug fix for a data race that can occur between creating and checking out connections when minPoolSize > 0.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.7.1(Aug 3, 2021)

    :warning: Retracted

    This release has been retracted due to a data race that can occur between creating and checking out connections when minPoolSize > 0.

    Please use version 1.7.2 or higher.


    The MongoDB Go driver team is pleased to release version 1.7.1 of the official Go driver.

    This release contains a bug fix and a minor documentation update:

    • A fix for a data race in appending connection options to the server config
    • A clarification in documentation of StartSession behavior

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
  • v1.6.1(Aug 3, 2021)

    :warning: Retracted

    This release has been retracted due to a data race that can occur between creating and checking out connections when minPoolSize > 0.

    Please use version 1.6.2 or higher.


    The MongoDB Go driver team is pleased to release version 1.6.1 of the official Go driver.

    This release contains a bug fix for a data race in appending connection options to the server config.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Release Notes

    For a full list of tickets included in this release, please see the link below:

    Source code(tar.gz)
    Source code(zip)
  • v1.7.0(Jul 20, 2021)

    :warning: Retracted

    This release has been retracted due to a data race that can occur between creating and checking out connections when minPoolSize > 0.

    Please use version 1.7.2 or higher.


    The MongoDB Go driver team is pleased to release version 1.7.0 of the official Go driver.

    This release supports additional features introduced in MongoDB version 5.0.

    Documentation can be found on pkg.go.dev and the MongoDB documentation site. BSON library documentation is also available on pkg.go.dev. Questions and inquiries can be asked on the MongoDB Developer Community. Bugs can be reported in the Go Driver Jira where a list of current issues can be found.

    Snapshot Reads Without Transaction

    Supports using the "snapshot" read concern outside of transactions for certain operations.

    Example of using a Session with "snapshot" read concern outside of a transaction for a Find operation:

    var client *mongo.Client
    
    // Create a new Session with "snapshot" reads enabled, then create a
    // SessionContext with the new Session.
    sess, err := client.StartSession(options.Session().SetSnapshot(true))
    if err != nil {
    	panic(err)
    }
    defer sess.EndSession(context.TODO())
    sessCtx := mongo.NewSessionContext(context.TODO(), sess)
    
    coll := client.Database("db").Collection("coll")
    cursor, err := coll.Find(sessCtx, bson.D{{"x", 1}})
    defer cursor.Close(context.TODO())
    
    // Use the cursor to read Find results with "snapshot" read concern.
    

    Detailed Document Validation Errors

    Surface the improved error messages for schema validation in MongoDB 5.0 in WriteException and BulkWriteException error messages and via the new field WriteError.Details.

    Release Notes

    For a full list of tickets included in this release, please see the links below:

    Source code(tar.gz)
    Source code(zip)
Owner
mongodb
mongodb
Mongo Go Models (mgm) is a fast and simple MongoDB ODM for Go (based on official Mongo Go Driver)

Mongo Go Models Important Note: We changed package name from github.com/Kamva/mgm/v3(uppercase Kamva) to github.com/kamva/mgm/v3(lowercase kamva) in v

kamva 607 Jan 2, 2023
The MongoDB driver for Go

The MongoDB driver for Go This fork has had a few improvements by ourselves as well as several PR's merged from the original mgo repo that are current

GlobalSign 2k Jan 8, 2023
The Go driver for MongoDB

MongoDB Go Driver The MongoDB supported driver for Go. Requirements Installation Usage Bugs / Feature Reporting Testing / Development Continuous Integ

mongodb 7.1k Dec 31, 2022
Go MySQL Driver is a MySQL driver for Go's (golang) database/sql package

Go-MySQL-Driver A MySQL-Driver for Go's database/sql package Features Requirements Installation Usage DSN (Data Source Name) Password Protocol Address

Go SQL Drivers 12.9k Jan 4, 2023
Go driver for PostgreSQL over SSH. This driver can connect to postgres on a server via SSH using the local ssh-agent, password, or private-key.

pqssh Go driver for PostgreSQL over SSH. This driver can connect to postgres on a server via SSH using the local ssh-agent, password, or private-key.

mattn 52 Nov 6, 2022
Simple key-value store abstraction and implementations for Go (Redis, Consul, etcd, bbolt, BadgerDB, LevelDB, Memcached, DynamoDB, S3, PostgreSQL, MongoDB, CockroachDB and many more)

gokv Simple key-value store abstraction and implementations for Go Contents Features Simple interface Implementations Value types Marshal formats Road

Philipp Gillé 501 Dec 24, 2022
Data access layer for PostgreSQL, CockroachDB, MySQL, SQLite and MongoDB with ORM-like features.

upper/db is a productive data access layer (DAL) for Go that provides agnostic tools to work with different data sources

upper.io 3.2k Jan 3, 2023
💲 Golang, Go Fiber, RabbitMQ, MongoDB, Docker, Kubernetes, GitHub Actions

Bank Projeto para simular empréstimos financeiros em um banco para clientes Tecnologias Utilizadas Golang MongoDB RabbitMQ Github Actions Docker Hub D

Jailton Junior 7 Dec 9, 2022
Examples and code to assign a name to your MongoDB, MySQL, PostgreSQL, RabbitMQ, and redis connection.

your connection deserves a name ?? When your app interacts with an external system, assign a name to the connection. An external system in this contex

Andy Grunwald 27 Dec 14, 2022
A MongoDB compatible embeddable database and toolkit for Go.

lungo A MongoDB compatible embeddable database and toolkit for Go. Installation Example Motivation Architecture Features License Installation To get s

Joël Gähwiler 400 Jan 3, 2023
Go-odm, a Golang Object Document Mapping for MongoDB.

A project of SENROK Open Source Go ODM Go-odm, a Golang Object Document Mapping for MongoDB. Table of contents Features Installation Get started Docum

SENROK 4 Nov 4, 2022
Golang MongoDB Integration Examples

Get Program Get a copy of the program: git clone https://github.com/hmdhszd/Go

Hamid Hosseinzadeh 1 Feb 1, 2022
Mirror of Apache Calcite - Avatica Go SQL Driver

Apache Avatica/Phoenix SQL Driver Apache Calcite's Avatica Go is a Go database/sql driver for the Avatica server. Avatica is a sub-project of Apache C

The Apache Software Foundation 103 Nov 3, 2022
Firebird RDBMS sql driver for Go (golang)

firebirdsql (Go firebird sql driver) Firebird RDBMS http://firebirdsql.org SQL driver for Go Requirements Firebird 2.5 or higher Golang 1.13 or higher

Hajime Nakagami 186 Dec 20, 2022
Microsoft ActiveX Object DataBase driver for go that using exp/sql

go-adodb Microsoft ADODB driver conforming to the built-in database/sql interface Installation This package can be installed with the go get command:

mattn 132 Dec 30, 2022
Microsoft SQL server driver written in go language

A pure Go MSSQL driver for Go's database/sql package Install Requires Go 1.8 or above. Install with go get github.com/denisenkom/go-mssqldb . Connecti

null 1.7k Dec 26, 2022
Oracle driver for Go using database/sql

go-oci8 Description Golang Oracle database driver conforming to the Go database/sql interface Installation Install Oracle full client or Instant Clien

mattn 598 Dec 30, 2022
sqlite3 driver for go using database/sql

go-sqlite3 Latest stable version is v1.14 or later not v2. NOTE: The increase to v2 was an accident. There were no major changes or features. Descript

mattn 6.3k Jan 8, 2023
GO DRiver for ORacle DB

Go DRiver for ORacle godror is a package which is a database/sql/driver.Driver for connecting to Oracle DB, using Anthony Tuininga's excellent OCI wra

null 409 Jan 5, 2023