{"id":13412367,"url":"https://github.com/mongodb/mongo-go-driver","last_synced_at":"2026-04-16T02:07:31.519Z","repository":{"id":37334327,"uuid":"81355383","full_name":"mongodb/mongo-go-driver","owner":"mongodb","description":"The Official Golang driver for MongoDB","archived":false,"fork":false,"pushed_at":"2026-04-09T18:50:56.000Z","size":46633,"stargazers_count":8519,"open_issues_count":8,"forks_count":924,"subscribers_count":115,"default_branch":"master","last_synced_at":"2026-04-09T20:27:37.902Z","etag":null,"topics":["database","driver","go","golang","golang-library","mongodb"],"latest_commit_sha":null,"homepage":"https://www.mongodb.com/docs/drivers/go/current/","language":"Go","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mongodb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"docs/CODEOWNERS","security":"docs/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2017-02-08T17:18:02.000Z","updated_at":"2026-04-08T09:32:42.000Z","dependencies_parsed_at":"2025-05-05T22:59:12.027Z","dependency_job_id":"da21e67d-2630-4451-a715-3e1c58665743","html_url":"https://github.com/mongodb/mongo-go-driver","commit_stats":{"total_commits":2142,"total_committers":161,"mean_commits":"13.304347826086957","dds":0.8169934640522876,"last_synced_commit":"b823409f1094fc54099bf64799a1e5a1d9e6fa67"},"previous_names":["10gen/mongo-go-driver"],"tags_count":156,"template":false,"template_full_name":null,"purl":"pkg:github/mongodb/mongo-go-driver","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-go-driver","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-go-driver/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-go-driver/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-go-driver/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mongodb","download_url":"https://codeload.github.com/mongodb/mongo-go-driver/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mongodb%2Fmongo-go-driver/sbom","scorecard":{"id":1084,"data":{"date":"2025-08-13T22:42:46Z","repo":{"name":"github.com/mongodb/mongo-go-driver","commit":"54bab6dd3e8ea728597da6d513265bc503a8293e"},"scorecard":{"version":"v5.2.1","commit":"ab2f6e92482462fe66246d9e32f642855a691dc1"},"score":6.5,"checks":[{"name":"Maintained","score":10,"reason":"30 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#maintained"}},{"name":"Dependency-Update-Tool","score":10,"reason":"update tool detected","details":["Info: detected update tool: Dependabot: .github/dependabot.yml:1"],"documentation":{"short":"Determines if the project uses a dependency update tool.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#dependency-update-tool"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#packaging"}},{"name":"Code-Review","score":8,"reason":"Found 20/23 approved changesets -- score normalized to 8","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#code-review"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#binary-artifacts"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#dangerous-workflow"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: jobLevel 'contents' permission set to 'write': .github/workflows/create-release-branch.yml:32","Info: jobLevel 'contents' permission set to 'read': .github/workflows/labeler.yml:8","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:32","Warn: jobLevel 'security-events' permission set to 'write': .github/workflows/release.yml:57","Warn: jobLevel 'contents' permission set to 'write': .github/workflows/release.yml:68","Info: jobLevel 'security-events' permission set to 'read': .github/workflows/release.yml:69","Warn: no topLevel permission defined: .github/workflows/check-labels.yml:1","Warn: no topLevel permission defined: .github/workflows/codeql.yml:1","Warn: no topLevel permission defined: .github/workflows/create-release-branch.yml:1","Warn: no topLevel permission defined: .github/workflows/labeler.yml:1","Warn: topLevel 'contents' permission set to 'write': .github/workflows/merge-up.yml:11","Warn: no topLevel permission defined: .github/workflows/release.yml:1","Info: topLevel permissions set to 'read-all': .github/workflows/scorecard.yml:18","Warn: no topLevel permission defined: .github/workflows/test.yml:1"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#token-permissions"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#security-policy"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: Apache License 2.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#license"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#cii-best-practices"}},{"name":"Pinned-Dependencies","score":1,"reason":"dependency not pinned by hash detected -- score normalized to 1","details":["Warn: third-party GitHubAction not pinned by hash: .github/workflows/check-labels.yml:16: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/check-labels.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:37: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/codeql.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/codeql.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/codeql.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/codeql.yml:53: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/codeql.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/create-release-branch.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/create-release-branch.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/create-release-branch.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/create-release-branch.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/create-release-branch.yml:46: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/create-release-branch.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/labeler.yml:12: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/labeler.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/merge-up.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/merge-up.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/merge-up.yml:30: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/merge-up.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:36: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:40: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:48: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:71: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:75: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/release.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/release.yml:82: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/release.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/scorecard.yml:76: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/scorecard.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/test.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/test.yml:21: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/test.yml/master?enable=pin","Warn: third-party GitHubAction not pinned by hash: .github/workflows/test.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/mongodb/mongo-go-driver/test.yml/master?enable=pin","Warn: containerImage not pinned by hash: Dockerfile:4","Warn: containerImage not pinned by hash: Dockerfile:20: pin your Docker image by updating artifactory.corp.mongodb.com/dockerhub/ubuntu:20.04 to artifactory.corp.mongodb.com/dockerhub/ubuntu:20.04@sha256:8feb4d8ca5354def3d8fce243717141ce31e2c428701f6682bd2fafe15388214","Warn: goCommand not pinned by hash: Dockerfile:54","Warn: goCommand not pinned by hash: etc/api_report.sh:20","Warn: goCommand not pinned by hash: etc/govulncheck.sh:14","Info:   2 out of  10 GitHub-owned GitHubAction dependencies pinned","Info:   1 out of  15 third-party GitHubAction dependencies pinned","Info:   0 out of   2 containerImage dependencies pinned","Info:   1 out of   4 goCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#pinned-dependencies"}},{"name":"SAST","score":10,"reason":"SAST tool is run on all commits","details":["Info: SAST configuration detected: CodeQL","Info: all commits (27) are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#sast"}},{"name":"Fuzzing","score":10,"reason":"project is fuzzed","details":["Info: OSSFuzz integration found","Info: GoBuiltInFuzzer integration found: bson/decode_value_fuzz_test.go:15","Info: GoBuiltInFuzzer integration found: bson/fuzz_test.go:18","Info: GoBuiltInFuzzer integration found: x/mongo/driver/operation/hello_test.go:708"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#fuzzing"}},{"name":"Signed-Releases","score":0,"reason":"Project has not signed or included provenance with any releases.","details":["Warn: release artifact v2.2.3 not signed: https://api.github.com/repos/mongodb/mongo-go-driver/releases/237789915","Warn: release artifact v2.2.2 not signed: https://api.github.com/repos/mongodb/mongo-go-driver/releases/223719875","Warn: release artifact v1.17.4 not signed: https://api.github.com/repos/mongodb/mongo-go-driver/releases/223478168","Warn: release artifact v2.2.1 not signed: https://api.github.com/repos/mongodb/mongo-go-driver/releases/216828800","Warn: release artifact v2.2.0 not signed: https://api.github.com/repos/mongodb/mongo-go-driver/releases/211348399","Warn: release artifact v2.2.3 does not have provenance: https://api.github.com/repos/mongodb/mongo-go-driver/releases/237789915","Warn: release artifact v2.2.2 does not have provenance: https://api.github.com/repos/mongodb/mongo-go-driver/releases/223719875","Warn: release artifact v1.17.4 does not have provenance: https://api.github.com/repos/mongodb/mongo-go-driver/releases/223478168","Warn: release artifact v2.2.1 does not have provenance: https://api.github.com/repos/mongodb/mongo-go-driver/releases/216828800","Warn: release artifact v2.2.0 does not have provenance: https://api.github.com/repos/mongodb/mongo-go-driver/releases/211348399"],"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#signed-releases"}},{"name":"Vulnerabilities","score":7,"reason":"3 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: GO-2025-3487 / GHSA-hcg3-q754-cr77","Warn: Project is vulnerable to: GO-2025-3829","Warn: Project is vulnerable to: GO-2024-3321 / GHSA-v778-237x-gjrc"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#vulnerabilities"}},{"name":"Branch-Protection","score":4,"reason":"branch protection is not maximal on development and all release branches","details":["Info: 'allow deletion' disabled on branch 'master'","Info: 'allow deletion' disabled on branch 'v1'","Info: 'allow deletion' disabled on branch 'release/1.13'","Info: 'allow deletion' disabled on branch 'release/1.12'","Info: 'force pushes' disabled on branch 'master'","Info: 'force pushes' disabled on branch 'v1'","Info: 'force pushes' disabled on branch 'release/1.13'","Info: 'force pushes' disabled on branch 'release/1.12'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'master'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'v1'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'release/1.13'","Warn: 'branch protection settings apply to administrators' is disabled on branch 'release/1.12'","Info: 'stale review dismissal' is required to merge on branch 'master'","Info: 'stale review dismissal' is required to merge on branch 'v1'","Info: 'stale review dismissal' is required to merge on branch 'release/1.13'","Info: 'stale review dismissal' is required to merge on branch 'release/1.12'","Warn: required approving review count is 1 on branch 'master'","Warn: required approving review count is 1 on branch 'v1'","Warn: required approving review count is 1 on branch 'release/1.13'","Warn: required approving review count is 1 on branch 'release/1.12'","Info: codeowner review is required on branch 'master'","Info: codeowner review is required on branch 'v1'","Info: codeowner review is required on branch 'release/1.13'","Info: codeowner review is required on branch 'release/1.12'","Warn: 'last push approval' is disabled on branch 'master'","Warn: 'last push approval' is disabled on branch 'v1'","Warn: 'last push approval' is disabled on branch 'release/1.13'","Warn: 'last push approval' is disabled on branch 'release/1.12'","Warn: 'up-to-date branches' is disabled on branch 'master'","Warn: 'up-to-date branches' is disabled on branch 'v1'","Warn: 'up-to-date branches' is disabled on branch 'release/1.13'","Warn: 'up-to-date branches' is disabled on branch 'release/1.12'","Info: status check found to merge onto on branch 'master'","Info: status check found to merge onto on branch 'v1'","Info: status check found to merge onto on branch 'release/1.13'","Info: status check found to merge onto on branch 'release/1.12'","Info: PRs are required in order to make changes on branch 'master'","Info: PRs are required in order to make changes on branch 'v1'","Info: PRs are required in order to make changes on branch 'release/1.13'","Info: PRs are required in order to make changes on branch 'release/1.12'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#branch-protection"}},{"name":"CI-Tests","score":10,"reason":"24 out of 24 merged PRs checked by a CI test -- score normalized to 10","details":null,"documentation":{"short":"Determines if the project runs tests before pull requests are merged.","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#ci-tests"}},{"name":"Contributors","score":10,"reason":"project has 21 contributing companies or organizations","details":["Info: found contributions from: 10gen, EpicGames, Math-Game-MCA, Princeton-SSI, avancemos, cmu-db, conda-forge, cyborginstitute, doctrine, glaredb, kframework, matplotlib, mongodb, mongodb-labs, open-telemetry, pion, princetoneclub, viam robotics, viam-labs, viamrobotics, winlabs"],"documentation":{"short":"Determines if the project has a set of contributors from multiple organizations (e.g., companies).","url":"https://github.com/ossf/scorecard/blob/ab2f6e92482462fe66246d9e32f642855a691dc1/docs/checks.md#contributors"}}]},"last_synced_at":"2025-08-14T12:32:29.673Z","repository_id":37334327,"created_at":"2025-08-14T12:32:29.674Z","updated_at":"2025-08-14T12:32:29.674Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31724423,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T13:21:33.774Z","status":"ssl_error","status_checked_at":"2026-04-12T13:21:29.265Z","response_time":58,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","driver","go","golang","golang-library","mongodb"],"created_at":"2024-07-30T20:01:23.928Z","updated_at":"2026-04-16T02:07:31.499Z","avatar_url":"https://github.com/mongodb.png","language":"Go","funding_links":[],"categories":["Popular","Misc","Go","开源类库","Middleware","Database Drivers","Libraries","Open source library","Data Management \u0026 Processing","数据库管理系统","数据库驱动程序","Data Integration Frameworks","数据库驱动","Generators","数据库驱动`连接和操作数据库工具`","NoSQL Databases","Database"],"sub_categories":["数据库","Advanced Console UIs","Go","Database","Database \u0026 Cloud Management","NoSQL Database Drivers","网络服务_其他","NoSQL数据库驱动程序","SQL 查询语句构建库"],"readme":"\u003cp align=\"center\"\u003e\u003cimg src=\"etc/assets/mongo-gopher.png\" width=\"250\"\u003e\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://goreportcard.com/report/go.mongodb.org/mongo-driver/v2\"\u003e\u003cimg src=\"https://goreportcard.com/badge/go.mongodb.org/mongo-driver/v2\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo\"\u003e\u003cimg src=\"etc/assets/godev-mongo-blue.svg\" alt=\"docs\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://pkg.go.dev/go.mongodb.org/mongo-driver/v2/bson\"\u003e\u003cimg src=\"etc/assets/godev-bson-blue.svg\" alt=\"docs\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://www.mongodb.com/docs/drivers/go/current/\"\u003e\u003cimg src=\"etc/assets/docs-mongodb-green.svg\"\u003e\u003c/a\u003e\n  \u003ca href=\"https://securityscorecards.dev/viewer/?uri=github.com/mongodb/mongo-go-driver\"\u003e\n    \u003cimg src=\"https://api.securityscorecards.dev/projects/github.com/mongodb/mongo-go-driver/badge\" alt=\"OpenSSF Scorecard\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\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/migration-2.0.md)\n- [v2.0 What's New](https://www.mongodb.com/docs/drivers/go/upcoming/whats-new/#what-s-new-in-2.0)\n\nThe MongoDB Go driver follows [semantic versioning](https://semver.org/) 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/mongo-driver` and having the build\nstep install the dependency or by explicitly running\n\n```bash\ngo get go.mongodb.org/mongo-driver/v2/mongo\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/mongo-driver/v2/mongo\"\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/mongo-driver/v2/mongo\"\n    \"go.mongodb.org/mongo-driver/v2/mongo/options\"\n    \"go.mongodb.org/mongo-driver/v2/mongo/readpref\"\n)\n\nclient, _ := mongo.Connect(options.Client().ApplyURI(\"mongodb://localhost: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://pkg.go.dev/go.mongodb.org/mongo-driver/v2/mongo#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/mongo-driver/v2/bson\"` 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/mongo-driver/v2/bson\"\n    \"go.mongodb.org/mongo-driver/v2/mongo\"\n    \"go.mongodb.org/mongo-driver/v2/mongo/options\"\n    \"go.mongodb.org/mongo-driver/v2/mongo/readpref\"\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(\u0026result); err != nil {\n      log.Fatal(err)\n    }\n\n    // 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(\u0026result)\nif errors.Is(err, mongo.ErrNoDocuments) {\n    // Do something when no record was found\n} else if err != nil {\n    log.Fatal(err)\n}\n\n// Do something with result...\n```\n\nAdditional examples and documentation can be found under the examples directory and [on the MongoDB Documentation website](https://www.mongodb.com/docs/drivers/go/current/).\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://google.github.io/snappy/) (`snappy`): available in MongoDB 3.4 and later.\n1. [Zlib](https://zlib.net/) (`zlib`): available in MongoDB 3.6 and later.\n1. [Zstandard](https://github.com/facebook/zstd/) (`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://pkg.go.dev/go.mongodb.org/mongo-driver/mongo/options#ClientOptions.SetCompressors):\n\n```go\nopts := options.Client().ApplyURI(\"mongodb://localhost:27017/?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://www.mongodb.com/docs/manual/reference/program/mongod/#std-option-mongod.--networkMessageCompressors).\n\nMessages compress when both parties enable network compression; otherwise, messages remain uncompressed\n\n## Support / Feedback\n\nFor issues with, questions about, or feedback for the Go Driver, please look into our [support channels](https://www.mongodb.com/docs/manual/support/), including [StackOverflow](https://stackoverflow.com/questions/tagged/mongodb%20go?sort=Newest).\n\nNew features and bugs can be reported on the [GODRIVER Jira project](https://jira.mongodb.org/browse/GODRIVER).\n\n## Contribution\n\nCheck out the [GODRIVER Jira project](https://jira.mongodb.org/browse/GODRIVER) for tickets that need completing. See our [contribution guidelines](docs/CONTRIBUTING.md) for details.\n\n## Continuous Integration\n\nCommits to master are run automatically on [evergreen](https://evergreen.mongodb.com/waterfall/mongo-go-driver).\n\n## Frequently Encountered Issues\n\nSee our [common issues](docs/common-issues.md) documentation for troubleshooting frequently encountered issues.\n\n## Thanks and Acknowledgement\n\n- The Go Gopher artwork by [@ashleymcnamara](https://github.com/ashleymcnamara)\n- The original Go Gopher was designed by [Renee French](http://reneefrench.blogspot.com/)\n\n## License\n\nThe MongoDB Go Driver is licensed under the [Apache License](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongo-go-driver","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmongodb%2Fmongo-go-driver","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmongodb%2Fmongo-go-driver/lists"}