Trên GitHub, mongodb/mongo-go-driver đã đạt 8.5k sao, nhóm Data, ngôn ngữ Go. The Official Golang driver for MongoDB
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
See the following resources to learn more about upgrading from version 1.x to 2.0.:
v2.0 Migration Guide
v2.0 What's New
The MongoDB Go Driver follows semantic versioning for its releases.
Requirements
Go 1.19 or higher. We aim to support the latest versions of Go.
Go 1.26 or higher is required to run the driver test suite.
MongoDB 4.2 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/v2/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/v2/mongo"
Usage
To get started with the driver, import the mongo package and create a mongo.Client with the Connect function:
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
if err := cur.Decode(&result); 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 errors.Is(err, mongo.ErrNoDocuments) {
// Do something when no record was found
} else 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.
Network Compression
Network compression will reduce bandwidth requirements between MongoDB and the application.
The Go Driver supports the following compression algorithms:
Snappy (snappy): available in MongoDB 3.4 and later.
Zlib (zlib): available in MongoDB 3.6 and later.
Zstandard (zstd): available in MongoDB 4.2 and later.
Specify Compression Algorithms
Compression can be enabled using the compressors parameter on the connection string or by using ClientOptions.SetCompressors:
If compressors are set, the Go Driver negotiates with the server to select the first common compressor. For server configuration and defaults, refer to networkMessageCompressors.
Messages compress when both parties enable network compression; otherwise, messages remain uncompressed
Support / Feedback
For issues with, questions about, or feedback for the Go Driver, please look into our support channels, including StackOverflow.
New features and bugs can be reported on the GODRIVER Jira project.
Contribution
Check out the GODRIVER Jira project for tickets that need completing. See our contribution guidelines for details.
Continuous Integration
Commits to master are run automatically on evergreen.
Frequently Encountered Issues
See our common issues documentation for troubleshooting frequently encountered issues.
Thanks and Acknowledgement
The Go Gopher artwork by @ashleymcnamara
The original Go Gopher was designed by Renee French
License
The MongoDB Go Driver is licensed under the Apache License.
mongodb/mongo-go-driver thuộc nhóm Data trên TopGit, cùng 6 topic GitHub. Trang Trending và Topics liệt kê các repo cùng số sao và cùng ngôn ngữ để so sánh.
Đọc thêm về mongodb/mongo-go-driver ở đâu?
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/mongodb/mongo-go-driver là nguồn chính thức.
mongodb/mongo-go-driver có bao nhiêu sao?
mongodb/mongo-go-driver có 8.5k sao GitHub — tải lại trang để xem số mới nhất, hoặc xem trực tiếp github.com/mongodb/mongo-go-driver. TopGit phản chiếu số sao của GitHub nhưng không cam kết đến từng phút.
mongodb/mongo-go-driver có những chủ đề gì?
GitHub topics của mongodb/mongo-go-driver: "database", "driver", "go", "golang", "golang-library", "mongodb". TopGit xếp repo vào nhóm Data.
mongodb/mongo-go-driver còn đang phát triển không?
Commit gần nhất trên mongodb/mongo-go-driver là 18 ngày trước (theo timestamp GitHub). Repo có 940 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
mongodb/mongo-go-driver viết bằng ngôn ngữ gì?
mongodb/mongo-go-driver chủ yếu viết bằng Go. Trường "language" của GitHub dựa trên phần lớn byte ở nhánh mặc định.
Vì sao mongodb/mongo-go-driver được xếp vào nhóm Data?
TopGit xếp mongodb/mongo-go-driver vào nhóm Data dựa trên GitHub topics và mô tả của repo (gắn thẻ: "database", "driver", "go"). Việc phân loại dựa trên metadata thật của repo, không phải đoán theo cảm tính biên tập.
Đọc đầy đủ README ở tab phía trên.
mongo-go-driver có đáng để bạn bỏ thời gian?
ChatGPT, Claude và Perplexity đều đọc được trang này. Hỏi thử xem họ nghĩ gì về mongo-go-driver.