MongoDB Go Driver


The recommended way to get started using the MongoDB Go driver is by using dep to install the dependency in your project:

dep ensure -add ""

See Installation

Connect to MongoDB Atlas

To connect to a MongoDB Atlas cluster, use the Atlas connection string for your cluster:

import ""

ctx, _ := context.WithTimeout(context.Background(), 10*time.Second)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(
if err != nil { log.Fatal(err) }

See Usage for more detail.


MongoDB Compatibility

Go Driver MongoDB 4.2 MongoDB 4.0 MongoDB 3.6 MongoDB 3.4 MongoDB 3.2 MongoDB 3.0 MongoDB 2.6

Language Compatibility

The MongoDB Go driver requires Go 1.10 or later.

How to get help