Docs Menu
Docs Home
/ / /
Go Driver
/

Upgrade Go driver Versions

This page describes the changes you must make to your application when you upgrade to a new version of Go driver.

A breaking change is a change of a convention or a behavior starting in a specific version of the driver. This type of change may prevent your application from working properly if not addressed before upgrading the driver.

The breaking changes in this section are categorized by the driver version that introduced them. When upgrading driver versions, address all the breaking changes between the current and upgrade versions.

  • Drops support for MongoDB Server v3.6. The minimum supported MongoDB Server version is now v4.0. This also drops support for the MONGODB-CR authentication mechanism. To learn more about compatibility with MongoDB Server versions, see the Compatibility reference.

  • mongo.Connect() does not accept a Context parameter. This method accepts only an options object. To view an example that uses this method, see the Connection Example Code in the Connection Guide.

  • The Cursor.SetMaxTime() method is renamed to Cursor.SetMaxAwaitTime(). This method specifies the maximum time that the server waits for new documents retrieved from a capped collection with a tailable cursor.

  • Removal of operation-specific timeout options. The following fields and setter methods have been removed from the driver:

    • AggregateOptions.MaxTime, AggregateOptions.SetMaxTime()

    • ClientOptions.SocketTimeout, ClientOptions.SetSocketTimeout()

    • CountOptions.MaxTime, CountOptions.SetMaxTime()

    • DistinctOptions.MaxTime, DistinctOptions.SetMaxTime()

    • EstimatedDocumentCountOptions.MaxTime, EstimatedDocumentCountOptions.SetMaxTime()

    • FindOptions.MaxTime, FindOptions.SetMaxTime()

    • FindOneOptions.MaxTime, FindOneOptions.SetMaxTime()

    • FindOneAndReplaceOptions.MaxTime, FindOneAndReplaceOptions.SetMaxTime()

    • FindOneAndUpdateOptions.MaxTime, FindOneAndUpdateOptions.SetMaxTime()

    • GridFSFindOptions.MaxTime, GridFSFindOptions.SetMaxTime()

    • CreateIndexesOptions.MaxTime, CreateIndexesOptions.SetMaxTime()

    • DropIndexesOptions.MaxTime, DropIndexesOptions.SetMaxTime()

    • ListIndexesOptions.MaxTime, ListIndexesOptions.SetMaxTime()

    • SessionOptions.DefaultMaxCommitTime, SessionOptions.SetDefaultMaxCommitTime()

    • TransactionOptions.MaxCommitTime, TransactionOptions.SetMaxCommitTime()

    • WriteConcern.WTimeout

    Instead, you can set a timeout on your client or within a Context. Learn more in the Limit Server Execution Time guide.

    • Removal of the bson/primitive package. This package is now merged with the bson package. To update your code, remove any bson/primitive import statements and change any instance of primitive.ObjectID to bson.ObjectId.

Back

Compatibility

On this page