[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-10415":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":22,"hasPages":22,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":16,"starSnapshotCount":16,"syncStatus":17,"lastSyncTime":33,"discoverSource":34},10415,"mongo-go-driver","mongodb\u002Fmongo-go-driver","mongodb","The Official Golang driver for MongoDB","https:\u002F\u002Fwww.mongodb.com\u002Fdocs\u002Fdrivers\u002Fgo\u002Fcurrent\u002F",null,"Go",8524,929,115,8,0,2,3,7,71.11,"Apache License 2.0",false,"master",[25,26,27,28,29,7],"database","driver","go","golang","golang-library","2026-06-12 04:00:50","\u003Cp align=\"center\">\u003Cimg src=\"etc\u002Fassets\u002Fmongo-gopher.png\" width=\"250\">\u003C\u002Fp>\n\u003Cp align=\"center\">\n  \u003Ca href=\"https:\u002F\u002Fgoreportcard.com\u002Freport\u002Fgo.mongodb.org\u002Fmongo-driver\u002Fv2\">\u003Cimg src=\"https:\u002F\u002Fgoreportcard.com\u002Fbadge\u002Fgo.mongodb.org\u002Fmongo-driver\u002Fv2\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpkg.go.dev\u002Fgo.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\">\u003Cimg src=\"etc\u002Fassets\u002Fgodev-mongo-blue.svg\" alt=\"docs\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fpkg.go.dev\u002Fgo.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fbson\">\u003Cimg src=\"etc\u002Fassets\u002Fgodev-bson-blue.svg\" alt=\"docs\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fwww.mongodb.com\u002Fdocs\u002Fdrivers\u002Fgo\u002Fcurrent\u002F\">\u003Cimg src=\"etc\u002Fassets\u002Fdocs-mongodb-green.svg\">\u003C\u002Fa>\n  \u003Ca href=\"https:\u002F\u002Fsecurityscorecards.dev\u002Fviewer\u002F?uri=github.com\u002Fmongodb\u002Fmongo-go-driver\">\n    \u003Cimg src=\"https:\u002F\u002Fapi.securityscorecards.dev\u002Fprojects\u002Fgithub.com\u002Fmongodb\u002Fmongo-go-driver\u002Fbadge\" alt=\"OpenSSF Scorecard\" \u002F>\n  \u003C\u002Fa>\n\u003C\u002Fp>\n\n# MongoDB Go Driver\n\nThe MongoDB supported driver for Go.\n\nSee the following resources to learn more about upgrading from version 1.x to 2.0.:\n\n- [v2.0 Migration Guide](docs\u002Fmigration-2.0.md)\n- [v2.0 What's New](https:\u002F\u002Fwww.mongodb.com\u002Fdocs\u002Fdrivers\u002Fgo\u002Fupcoming\u002Fwhats-new\u002F#what-s-new-in-2.0)\n\nThe MongoDB Go driver follows [semantic versioning](https:\u002F\u002Fsemver.org\u002F) for its releases.\n\n## Requirements\n\n- Go 1.19 or higher. We aim to support the latest versions of Go.\n- Go 1.25 or higher is required to run the driver test suite.\n- MongoDB 4.2 and higher.\n\n## Installation\n\nThe recommended way to get started using the MongoDB Go driver is by using Go modules to install the dependency in\nyour project. This can be done either by importing packages from `go.mongodb.org\u002Fmongo-driver` and having the build\nstep install the dependency or by explicitly running\n\n```bash\ngo get go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\n```\n\nWhen using a version of Go that does not support modules, the driver can be installed using `dep` by running\n\n```bash\ndep ensure -add \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\"\n```\n\n## Usage\n\nTo get started with the driver, import the `mongo` package and create a `mongo.Client` with the `Connect` function:\n\n```go\nimport (\n    \"context\"\n    \"time\"\n\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\"\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\u002Foptions\"\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\u002Freadpref\"\n)\n\nclient, _ := mongo.Connect(options.Client().ApplyURI(\"mongodb:\u002F\u002Flocalhost:27017\"))\n```\n\nMake sure to defer a call to `Disconnect` after instantiating your client:\n\n```go\ndefer func() {\n    if err := client.Disconnect(ctx); err != nil {\n        panic(err)\n    }\n}()\n```\n\nFor more advanced configuration and authentication, see the [documentation for mongo.Connect](https:\u002F\u002Fpkg.go.dev\u002Fgo.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo#Connect).\n\nCalling `Connect` does not block for server discovery. If you wish to know if a MongoDB server has been found and connected to,\nuse the `Ping` method:\n\n```go\nctx, cancel := context.WithTimeout(context.Background(), 2*time.Second)\ndefer cancel()\n\n_ = client.Ping(ctx, readpref.Primary())\n```\n\nTo insert a document into a collection, first retrieve a `Database` and then `Collection` instance from the `Client`:\n\n```go\ncollection := client.Database(\"testing\").Collection(\"numbers\")\n```\n\nThe `Collection` instance can then be used to insert documents:\n\n```go\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\n\nres, _ := collection.InsertOne(ctx, bson.D{{\"name\", \"pi\"}, {\"value\", 3.14159}})\nid := res.InsertedID\n```\n\nTo use `bson.D`, you will need to add `\"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fbson\"` to your imports.\n\nYour import statement should now look like this:\n\n```go\nimport (\n    \"context\"\n    \"log\"\n    \"time\"\n\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fbson\"\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\"\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\u002Foptions\"\n    \"go.mongodb.org\u002Fmongo-driver\u002Fv2\u002Fmongo\u002Freadpref\"\n)\n```\n\nSeveral query methods return a cursor, which can be used like this:\n\n```go\nctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)\ndefer cancel()\n\ncur, err := collection.Find(ctx, bson.D{})\nif err != nil {\n  log.Fatal(err)\n}\n\ndefer cur.Close(ctx)\nfor cur.Next(ctx) {\n    var result bson.D\n    if err := cur.Decode(&result); err != nil {\n      log.Fatal(err)\n    }\n\n    \u002F\u002F do something with result....\n}\n\nif err := cur.Err(); err != nil {\n    log.Fatal(err)\n}\n```\n\nFor methods that return a single item, a `SingleResult` instance is returned:\n\n```go\nvar result struct {\n    Value float64\n}\n\nfilter := bson.D{{\"name\", \"pi\"}}\nctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)\ndefer cancel()\n\nerr := collection.FindOne(ctx, filter).Decode(&result)\nif errors.Is(err, mongo.ErrNoDocuments) {\n    \u002F\u002F Do something when no record was found\n} else if err != nil {\n    log.Fatal(err)\n}\n\n\u002F\u002F Do something with result...\n```\n\nAdditional examples and documentation can be found under the examples directory and [on the MongoDB Documentation website](https:\u002F\u002Fwww.mongodb.com\u002Fdocs\u002Fdrivers\u002Fgo\u002Fcurrent\u002F).\n\n### Network Compression\n\nNetwork compression will reduce bandwidth requirements between MongoDB and the application.\n\nThe Go Driver supports the following compression algorithms:\n\n1. [Snappy](https:\u002F\u002Fgoogle.github.io\u002Fsnappy\u002F) (`snappy`): available in MongoDB 3.4 and later.\n1. [Zlib](https:\u002F\u002Fzlib.net\u002F) (`zlib`): available in MongoDB 3.6 and later.\n1. [Zstandard](https:\u002F\u002Fgithub.com\u002Ffacebook\u002Fzstd\u002F) (`zstd`): available in MongoDB 4.2 and later.\n\n#### Specify Compression Algorithms\n\nCompression can be enabled using the `compressors` parameter on the connection string or by using [`ClientOptions.SetCompressors`](https:\u002F\u002Fpkg.go.dev\u002Fgo.mongodb.org\u002Fmongo-driver\u002Fmongo\u002Foptions#ClientOptions.SetCompressors):\n\n```go\nopts := options.Client().ApplyURI(\"mongodb:\u002F\u002Flocalhost:27017\u002F?compressors=snappy,zlib,zstd\")\nclient, _ := mongo.Connect(opts)\n```\n\n```go\nopts := options.Client().SetCompressors([]string{\"snappy\", \"zlib\", \"zstd\"})\nclient, _ := mongo.Connect(opts)\n```\n\nIf compressors are set, the Go Driver negotiates with the server to select the first common compressor. For server configuration and defaults, refer to [`networkMessageCompressors`](https:\u002F\u002Fwww.mongodb.com\u002Fdocs\u002Fmanual\u002Freference\u002Fprogram\u002Fmongod\u002F#std-option-mongod.--networkMessageCompressors).\n\nMessages compress when both parties enable network compression; otherwise, messages remain uncompressed\n\n## Support \u002F Feedback\n\nFor issues with, questions about, or feedback for the Go Driver, please look into our [support channels](https:\u002F\u002Fwww.mongodb.com\u002Fdocs\u002Fmanual\u002Fsupport\u002F), including [StackOverflow](https:\u002F\u002Fstackoverflow.com\u002Fquestions\u002Ftagged\u002Fmongodb%20go?sort=Newest).\n\nNew features and bugs can be reported on the [GODRIVER Jira project](https:\u002F\u002Fjira.mongodb.org\u002Fbrowse\u002FGODRIVER).\n\n## Contribution\n\nCheck out the [GODRIVER Jira project](https:\u002F\u002Fjira.mongodb.org\u002Fbrowse\u002FGODRIVER) for tickets that need completing. See our [contribution guidelines](docs\u002FCONTRIBUTING.md) for details.\n\n## Continuous Integration\n\nCommits to master are run automatically on [evergreen](https:\u002F\u002Fevergreen.mongodb.com\u002Fwaterfall\u002Fmongo-go-driver).\n\n## Frequently Encountered Issues\n\nSee our [common issues](docs\u002Fcommon-issues.md) documentation for troubleshooting frequently encountered issues.\n\n## Thanks and Acknowledgement\n\n- The Go Gopher artwork by [@ashleymcnamara](https:\u002F\u002Fgithub.com\u002Fashleymcnamara)\n- The original Go Gopher was designed by [Renee French](http:\u002F\u002Freneefrench.blogspot.com\u002F)\n\n## License\n\nThe MongoDB Go Driver is licensed under the [Apache License](LICENSE).\n","该项目是MongoDB官方提供的Go语言驱动程序，旨在帮助开发者使用Go语言高效地与MongoDB数据库进行交互。其核心功能包括连接管理、CRUD操作支持以及高级查询能力等，并且遵循语义化版本控制策略以确保稳定性和兼容性。该驱动程序利用了Go语言的并发特性来优化性能，并提供了丰富的选项设置以便于灵活配置。适用于需要在Go应用中集成MongoDB作为数据存储解决方案的各种场景，如构建微服务架构、开发后端API或是处理大规模数据分析任务时。","2026-06-11 03:28:17","top_topic"]