The Official Golang driver for MongoDB
v1.11.8 has been retracted because it incorrectly contains minor release changes intended for 1.12.1.
Please use version 1.11.9 or higher.
The MongoDB Go Driver Team is pleased to release version 1.12.1 of the official Go driver.
This release fixes a bug in the Go Driver where connections are leaked if a user runs a transaction while connected to a load balancer. To resolve this issue, the Go Driver will now unpin connections when ending a session.
This release fixes a logging design oversight in which enabling logging with "options.LogComponentAll" does not result in the publication of logs.
This release fixes two runtime errors, which occur on unmarshaling an empty bson.RawValue with an invalid type, specifically the 0x00 (null) type, and on marshaling a nil pointer of ReadConcern.
For a full list of tickets included in this release, please see the links below:
Full Changelog: v1.12.0...v1.12.1
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!
The MongoDB Go Driver Team is pleased to release version 1.12.0 of the official Go driver.
This release adds support for MongoDB 7.0, including production-ready support for Queryable Encryption. It also adds a new logging interface and configuration API improvements.
This release introduces backwards breaking changes to the Queryable Encryption protocol. Using Queryable Encryption now requires MongoDB 7.0+ and libmongocrypt v1.8.0+.
It also adds the new ClientEncryption.CreateEncryptedCollection
method to automatically create data encryption keys when creating a new encrypted collection and adds the ability to fetch KMS credentials automatically from Azure, GCP, and AWS environments.
This release introduces a logging interface to allow users to more easily record detailed information about connection management and command execution within their application.
The logging configuration adds a new LogSink
interface that is compatible with the logr.LogSink interface, allowing users to use existing logr
adapters, like zerologr or zapr. Users may also implement their own LogSink
adapter.
For example, to integrate logging with an existing zerolog logger:
sink := zerologr.New(&myLogger).GetSink()
loggerOptions := options.Logger().SetSink(sink)
options.Client().SetLoggerOptions(loggerOptions)
Logging can also be enabled using environment variables. For example, to enable command logging at info level to client.log
, set:
export MONGODB_LOG_COMMAND=info
export MONGODB_LOG_MAX_DOCUMENT_LENGTH=100
export MONGODB_LOG_PATH="client.log"
The options
package has a new way to set various BSON marshaling and unmarshaling behaviors.
For example, to set BSON options that cause the Go driver to fallback to "json" struct tags if "bson" struct tags are missing, marshal nil
Go maps as empty BSON documents, and marshals nil
Go slices as empty BSON arrays, use the new options.BSONOptions
configuration:
bsonOpts := &options.BSONOptions{
UseJSONStructTags: true,
NilMapAsEmpty: true,
NilSliceAsEmpty: true,
}
options.Client().SetBSONOptions(bsonOpts)
The writeconcern
package has new convenience functions Majority
, W1
, Journaled
, and Unacknowledged
for creating common write concerns.
For example, to configure a Client
to use write concern {w: 1}, use the new writeconcern.W1()
function:
options.Client().SetWriteConcern(writeconcern.W1())
SetBatchSize
to Cursor
to allow specifying the size of batches fetched from the database when iterating a cursor. It is primarily intended for use with cursors returned by RunCommandCursor.bson.UnmarshalValue
to allow unmarshaling BSON values that were marshaled using the existing bson.MarshalValue.For a full list of tickets included in this release, please see the links below:
Full Changelog: v1.11.7...1.12.0
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!
The MongoDB Go Driver Team is pleased to release version 1.11.7 of the official Go driver.
This release fixes various bugs, including:
decimal128
values from Extended JSON can take a long time.RewrapManyDataKey
should return an error if it's called with masterKey
and without provider
.int64
.It also adds the Cursor.SetBatchSize
API, which allows changing the document batch size requested for subsequent cursor iterations.
For a full list of tickets included in this release, please see the links below:
Full Changelog: v1.11.6...1.11.7
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!
The MongoDB Go Driver Team is pleased to release version 1.11.6 of the official Go driver.
This release fixes the import failure introduced in 1.11.5.
This release also includes the patch in the retracted 1.11.5, which fixes a bug that can squash the FullDocument
configuration value when merging multiple ChangeStreamOptions
structs.
For a full list of tickets included in this release, please see the links below:
Full Changelog: v1.11.4...v1.11.6
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!
This release has been retracted due to an import failure.
Please use version 1.11.6 or higher.
The MongoDB Go Driver Team is pleased to release version 1.11.5 of the official Go driver.
This release fixes a bug that can squash the FullDocument
configuration value when merging multiple ChangeStreamOptions
structs.
For a full list of tickets included in this release, please see the links below:
Full Changelog: v1.11.4...v1.11.5
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!
The MongoDB Go Driver Team is pleased to release version 1.11.4 of the official Go driver.
This release includes optimizations to reduce memory consumption in reading compressed wire messages. The release also offers codec support for decoding struct container fields as either map or document types, rather than an ancestor type.
Additionally, the mongo package will support a closed approach for checking transaction error labels. For example:
err = client.Ping(ctx, nil)
var le mongo.LabeledError
if errors.As(err, &le) && le.HasErrorLabel("TransientTransactionError") {
log.Fatalf("transient transaction error: %v", le)
}
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!
The MongoDB Go Driver Team is pleased to release version 1.11.3 of the official Go driver.
This release reduces memory usage under some query workloads and fixes a bug that can cause undefined behavior when reading the Raw
field on database error types, including CommandError
and WriteException
.
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!
This release has been retracted due to a bug that can cause undefined behavior when reading the Raw
field on database error types, including CommandError
and WriteException
.
Please use version 1.11.3 or higher.
The MongoDB Go Driver Team is pleased to release version 1.11.2 of the official Go driver.
This release includes various bug fixes.
bson.Raw
to Extended JSONPreviously, calling bson.Raw.String
would output the wrong Extended JSON type if the BSON document contained a "UTC timestamp" field. This release updates String
to output the correct Extended JSON type for timestamps.
Previously, retried reads could fail if an operation used read concern "linearizable" or "available" because the Go driver set a conflicting configuration for implicit sessions. This release resolves conflicts with "linearizable" or "available" read concerns in retried reads.
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!
The MongoDB Go Driver Team is pleased to release version 1.10.6 of the official Go driver.
This release resolves a panic when aborting a transaction. More specifically, from the pull request:
Users are occasionally seeing panics from the ServerConnectionID() call here. The driver was panic'ing because topology.Connection did not implement a ServerConnectionID() method that guarded against the underlying, embedded connection being nil.
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!
The MongoDB Go Driver Team is pleased to release version 1.12.0-alpha1 of the official Go driver.
This release includes an experimental API for explicitly encrypting a range index, a patch to retry heartbeat on timeout, the deprecation of the x/bsonx package, as well as various performance optimizations to server selection functions.
Support "RangeOptions" for specifying index options for a Queryable Encryption field supporting "rangePreview" queries. This is an experimental feature.
A patch to retry heartbeat on timeout errors to delay pool cleanup by one event loop.
When adding a client certificate from bytes, the subject of the last certificate was being returned as the username for X509 auth after GODRIVER-2263, which did not match the order of loading a PEM file with multiple certs. This change updates the certificate subject string if the certDecodeBlock is never set.
The bsonx package contains Doc, Arr, Elem, and Val types that are largely unused. These were a POC of a type-safe BSON API and were used extensively in the 1.0 driver, but the usages were replaced by bsoncore in v1.1.
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!