MongoDB’s supported Go driver connects applications to MongoDB for CRUD, aggregation, indexing, and secure access. Install via Go modules from go.mongodb.org/mongo-driver.
Overview
The MongoDB Go driver is the supported way for Go programs to connect to MongoDB deployments, discover servers, and run reads and writes. You import the mongo package, create a Client with Connect, and defer Disconnect when finished. Connect does not block on discovery; Ping can confirm that a server is reachable.
Guides walk through databases and collections, CRUD, aggregation, specialized data formats, indexes, database commands, time series collections, monitoring, logging, and security. The context package is used to manage blocking calls. Documentation also covers connection troubleshooting and API details for types and methods.
Network compression can shrink traffic between the application and MongoDB when both sides support it. The driver can negotiate Snappy and related compressors via connection options or connection strings. MongoDB Search and MongoDB Vector Search material describes running those query types from Go.
Semantic versioning governs releases. The driver targets recent Go toolchains and MongoDB 4.4 or newer. Examples and extended reference material live in the official docs site and bundled examples.
Key features
- mongo.Client connection API
- CRUD via Database and Collection
- Aggregation pipelines
- Index management
- Network compression negotiation
- Context-aware blocking calls
- MongoDB Search queries
- Security and authentication options
Use cases
- Go services backed by MongoDB
- CRUD and cursor-based reads
- Aggregation and reporting
- Compressed connections to MongoDB
- Atlas Search and vector queries from Go