mongo-go-driver
AGENTS.md8.5k starsChanged 7 months agoApache-2.0View on GitHub
Official MongoDB Go Driver (go.mongodb.org/mongo-driver/v2). Correctness, backward compatibility, and conformance to MongoDB Driver Specifications are top priorities. Uses Task, not make. Tests require a running mongod on localhost:27017 (or MONGODB_URI). The full test suite is serial (-p 1) — integration tests share server state. Do not parallelize. Evergreen's project configuration lives in .evergreen/config.yml, where every task, variant, and expansion is declared; supporting CI scripts live alongside it. Validate any change with evergreen validate -p mongo-go-driver -f .evergreen/config.yml (authenticate with evergreen…
Trending
Quiet since July.about the whole repository
Who's talking about mongodb/mongo-go-driver
- golang-migrate/migrate“Too many dependencies”GitHub · Feb 17, 2019 · 23 reactions
- upper/db“Update mongodb support?”GitHub · Mar 9, 2019 · 9 reactions
- yorkie-team/yorkie“Introduce sharding rules to MongoDB collections”GitHub · Nov 9, 2023 · 6 reactions
- golang/go“proposal: cmd/go: add an option to sequentially run tests”GitHub · Jul 12, 2023 · 5 reactions
- golang/go“x/tools/cmd/goimports: goimports destroys import groups”GitHub · Oct 24, 2018 · 5 reactions
The biggest 5 of 29 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 29
Talked about on GitHub and Hacker News (29 times).
On GitHub · 28
- Feb 17, 2019Too many dependencies — golang-migrate/migrate23 reactions · 29 comments
- Mar 9, 2019Update mongodb support? — upper/db9 reactions
- Nov 9, 2023Introduce sharding rules to MongoDB collections — yorkie-team/yorkie6 reactions · 1 comment
- Jul 12, 2023proposal: cmd/go: add an option to sequentially run tests — golang/go5 reactions · 6 comments
- Oct 24, 2018x/tools/cmd/goimports: goimports destroys import groups — golang/go5 reactions · 3 comments
23 more on GitHub
- Nov 18, 2025Update to latest mongo go drivers — rwynn/monstache3 reactions
- Feb 18, 2025Upgrade mongo-driver to V2 — golang-migrate/migrate3 reactions · 3 comments
- Dec 5, 2023Internal panic (conflicting position information on upstream object) with latest rules_go — uber-go/nilaway3 reactions · 9 comments
- Jul 17, 2026chore(deps): bump the go_modules group across 6 directories with 3 updates — CaffeeLake/external-secrets2 reactions · 1 comment
- Jul 17, 2026chore(deps): bump the go_modules group across 6 directories with 2 updates — CaffeeLake/external-secrets2 reactions · 2 comments
- Jul 10, 2026chore(deps): bump the go_modules group across 61 directories with 4 updates — CaffeeLake/external-secrets2 reactions · 2 comments
- Jul 10, 2026chore(deps): bump the go_modules group across 61 directories with 4 updates — CaffeeLake/external-secrets2 reactions · 2 comments
- Jul 7, 2026chore(deps): bump the go_modules group across 3 directories with 2 updates — CaffeeLake/hydra2 reactions · 2 comments
- Jul 4, 2026chore(deps): bump the go_modules group across 4 directories with 2 updates — CaffeeLake/keto2 reactions · 2 comments
- Jul 4, 2026chore(deps): bump the go_modules group across 3 directories with 3 updates — CaffeeLake/oathkeeper2 reactions · 2 comments
- Jul 3, 2026chore(deps): bump the go_modules group across 2 directories with 8 updates — nexusct/1Panel2 reactions · 3 comments
- Jul 3, 2026chore(deps): bump the go_modules group across 11 directories with 4 updates — CaffeeLake/external-secrets2 reactions · 2 comments
- Jul 3, 2026chore(deps): bump the go_modules group across 3 directories with 2 updates — CaffeeLake/keto2 reactions · 1 comment
- Jul 3, 2026chore(deps): bump the go_modules group across 2 directories with 2 updates — CaffeeLake/oathkeeper2 reactions · 2 comments
- Jun 24, 2026Bump the go_modules group across 2 directories with 14 updates — CaffeeLake/Cosmos-Server2 reactions
- Jun 24, 2026chore(deps): bump go.mongodb.org/mongo-driver from 1.17.4 to 1.17.7 in /oryx in the go_modules group across 1 directory — CaffeeLake/oathkeeper2 reactions · 1 comment
- Jun 24, 2026build(deps): bump the go_modules group across 1 directory with 13 updates — CaffeeLake/terraformer2 reactions
- Jun 24, 2026chore(deps): bump the go_modules group across 3 directories with 1 update — CaffeeLake/kratos2 reactions · 1 comment
- Jun 24, 2026chore(deps): bump the go_modules group across 6 directories with 3 updates — CaffeeLake/external-secrets2 reactions · 1 comment
- Jun 24, 2026chore(deps): bump the go_modules group across 2 directories with 1 update — CaffeeLake/keto2 reactions · 1 comment
- Jun 21, 2026chore(deps): bump go.mongodb.org/mongo-driver from 1.14.0 to 1.17.7 — Dustin4444/slsa-github-generator2 reactions · 3 comments
- Feb 27, 2024Goto label undefined — traefik/yaegi2 reactions
- Jun 14, 2018Mongo DB and Hyper SQL support — xo/usql2 reactions · 3 comments
On Hacker News · 1
- Mar 7, 2018MongoDB Go Driver Alpha 21 point
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
The file
We split this AGENTS.md into the rules it gives an agent
7 rules. About 0 are common, 1 is distinctive, and 6 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
6
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 43
Add a value at the top of the version axis (id/display_name/variables: VERSION:).
- Distinctive: line 64
CSOT timeouts: Use context deadlines; do not introduce per-call wall-clock timers that race with the user's context.
- Very specific: line 65
Command monitoring redacts credentials: When adding commands that handle credentials (authenticate, saslStart, etc.), add them to the …
- Very specific: line 72
Context: Every blocking public method takes context.Context as its first argument.
- Very specific: line 75
New options: Follow the setter pattern: func (o *XxxOptionsBuilder) SetFoo(v T) *XxxOptionsBuilder.
- Very specific: line 79
Use internal/assert (wraps testify) for assertions.
- Very specific: line 89
Run task (default target) before every PR.
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS.md
This file provides guidance to AI agents when working with code in this repository.
Project
Official MongoDB Go Driver (go.mongodb.org/mongo-driver/v2). Correctness, backward compatibility, and conformance to MongoDB Driver Specifications are top priorities.
- Module:
go.mongodb.org/mongo-driver/v2 - Issue tracker: JIRA GODRIVER project — GitHub Issues is not used for bugs/features
- Active major version: v2 on
master. v1 lives onrelease/1.xbranches.
Build, test, and lint
Uses Task, not make.
task # default: build + check-license + check-fmt + check-modules + lint + test-short
task fmt # gofumpt -w . — use this, not plain gofmt
task build # includes compilecheck (all supported Go versions, needs Docker)
task lint # golangci-lint across linux/{386,arm,arm64,amd64,ppc64le,s390x}
task test-short # race detector, ~60s timeout — fast feedback
task test # full suite, serial (-p 1), 1800s timeout, requires mongod
task api-report # required when public API changes — include output in PR descriptionTests require a running mongod on localhost:27017 (or MONGODB_URI). The full test suite is serial (-p 1) — integration tests share server state. Do not parallelize.
Go version requirements
- Go 1.25: minimum to compile/use the driver. The Go Driver supports the last two Go minor versions. Public packages (
mongo/,bson/,event/,tag/) must build on 1.25. Thecompilechecktask enforces this at build time, compiling against every version ingoVersions(internal/test/compilecheck/compile_check_test.go). - Go 1.26+: required to run the test suite and develop the driver.
CI (Evergreen)
Evergreen's project configuration lives in .evergreen/config.yml, where every task, variant, and expansion is declared; supporting CI scripts live alongside it. Validate any change with
evergreen validate -p mongo-go-driver -f .evergreen/config.yml (authenticate with evergreen login, not an API key). Warnings about unused tasks and merge-queue aliases are pre-existing.
Two submodules, both pinned by commit. .evergreen/drivers-evergreen-tools (DET) provides every server-provisioning script; testdata/specifications provides spec-test fixtures. CI checks out the pinned commits (git submodule update --init in the setup-system function) — it does not track DET master. So a fix that has landed upstream in DET is not live here until the pin moves. Run task init-submodule locally before inspecting DET; it is often left uninitialized.
Adding a new server version:
- Add a value at the top of the
versionaxis (id/display_name/variables: VERSION:). - Append it to each relevant
matrix_specversion list. Matrices taggedpullrequestrun on every PR; untagged ones are waterfall-only. Convention is that the newest version gets the PR-tagged matrix and the previous newest falls back to the waterfall matrix. - Variants not expanded across the
versionaxis need editing by hand — notablytestoidc_task_group, which hardcodesMONGODB_VERSION. Task groups cannot take a matrix axis, and a task may appear only once per buildvariant.
When a version won't download, the fix usually belongs in DET, not here. VERSION flows to mongodl unchanged (bootstrap-mongo-orchestration → run-orchestration.sh → drivers_orchestration.py), and mongodl resolves a bare X.Y to the newest X.Y.* in full.json, release candidates included. Pre-GA versions are often absent from full.json, and DET carries the workaround (e.g. UNPUBLISHED_VERSIONS maps such a version to its branch nightly). Prefer bumping the DET pin over adding driver-side overrides such as MONGODB_DOWNLOAD_SOURCE:
cd .evergreen/drivers-evergreen-tools
git fetch origin
git checkout <upstream-commit> # or origin/master
cd -
git add .evergreen/drivers-evergreen-toolsDependabot bumps this pin routinely, so prefer waiting for its PR when the fix is not urgent. Bumping by hand pulls in every intervening upstream commit — review git log <old>..<new> for unrelated CI changes and validate in a patch build (evergreen patch -p mongo-go-driver -u), not just evergreen validate.
Gotchas
x/packages are importable but not semver-covered. Users do importx/mongo/driveretc. Flag breaking changes explicitly in PR descriptions even though semver doesn't require it.- Atomic alignment on 32-bit.
int64/uint64fields accessed viasync/atomicmust be at struct start or useatomic.Int64. The lint pass onGOARCH=386catches this — don't skip cross-arch lint. - GridFS lives in
mongo/. v2 mergedgridfs.Bucketintomongo.GridFSBucket. Don't resurrect the oldgridfsimport path. - CSOT timeouts. Use context deadlines; do not introduce per-call wall-clock timers that race with the user's context.
- Command monitoring redacts credentials. When adding commands that handle credentials (
authenticate,saslStart, etc.), add them to the redaction list. libmongocryptrequired for CSFLE/QE tests. Install withtask install-libmongocrypt. CSFLE code requires thecsebuild tag.
Code conventions
- Formatter:
gofumpt(stricter superset of gofmt). Always usetask fmt, never plain gofmt. - Errors:
fmt.Errorf("…: %w", err)for wrapping. Useerrors.Is/errors.Asfor comparisons — neverstrings.Containson error messages. Sentinel errors live in themongopackage (mongo.ErrNoDocuments, etc.). - Context: Every blocking public method takes
context.Contextas its first argument. Usemongo.SessionFromContext(ctx)(v2 pattern) — not the oldmongo.SessionContext. - BSON:
bson.Dfor ordered documents and commands.bson.Monly when order genuinely doesn't matter.bsoncore.Documentin hot paths (zero-copy, byte-slice-backed). - Exported names: Full words, not abbreviations (
ClientBulkWriteResult, notCBWResult). Doc comments required on all exported identifiers using the "name is subject" convention. - New options: Follow the setter pattern:
func (o *XxxOptionsBuilder) SetFoo(v T) *XxxOptionsBuilder.
Tests
- Use
internal/assert(wraps testify) for assertions. Preferassert.ErrorIsoverassert.ErrorContains. - Integration tests: use
internal/integration/mtestfor topology-aware setup, fail-point injection, and event capture. - Spec tests: JSON/YAML fixtures under
testdata/(git submodule — runtask init-submoduleafter cloning if missing). - Prose tests: number them to match the spec (e.g.,
"3. bulkWrite batch splits…") for cross-referencing. - Unit tests live next to the code (
foo.go↔foo_test.go). Integration tests live ininternal/integration/.
PR and commit conventions
- JIRA prefix required:
GODRIVER-1234 Short descriptionfor all commit messages and PR titles. - Features →
master. Bug fixes → latest stable release branch (e.g.,release/2.5). The "Merge up" GitHub Action propagates fixes to newer branches automatically. - Run
task(default target) before every PR. - Changed public API (
mongo/,bson/,event/,tag/)? Runtask api-reportand include the output in the PR description. - User-visible breaking change? Update
docs/migration-2.0.md. - Spec compliance changes? Quote the relevant spec requirement in the PR description.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

