You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Part of the easymongo refactor (see PLAN.md on the refactor branch). Last code step, after the driver migration is complete.
Working context (read this first)
Repository github.com/tophergopher/easymongo. Start from branch claude/mongotest-easymongo-refactor-wu2vhm; create a branch issue-<number>-<short-slug> from it and open a pull request back into it. PLAN.md on that branch is the source of truth; read it before writing code.
Go project, single module, all packages at the repo root except the new easymongotest/ subpackage. The final toolchain target is Go 1.27 (set by Toolchain: go 1.27, latest dependencies, tidy, remove replace directives #10); any Go 1.24 or newer works until then. Before pushing: gofmt -l . prints nothing, go vet ./..., go test -race ./....
The existing test suite (*_test.go at the root, package easymongo_test, every test function calling setup(t) from common_test.go) is the regression net for this refactor. It must pass after your change. It needs a Docker daemon reachable through the normal Docker environment and the mongo:8 image.
Method is test-driven: write the tests listed under "Tests first", confirm they fail for the expected reason, then implement. Never delete, skip or weaken an existing test to get green; if a test must change because the public API changed (for example primitive.ObjectID to bson.ObjectID), change only the types.
Commit messages: imperative summary line, blank line, body explaining why. Mention this issue number in the pull request description.
Scope
go 1.27 directive in go.mod.
Dependencies at their latest releases: go.mongodb.org/mongo-driver/v2 (2.9.x or newer), github.com/stretchr/testify, github.com/tophergopher/mongotest/v2 at its first tagged release. Remove go.mongodb.org/mongo-driver (v1), docker.io/go-docker, github.com/gogo/protobuf, github.com/sirupsen/logrus, github.com/tophergopher/mongotest (v1 path).
Delete both commented replace lines and any temporary replace ../mongotest/v2 used during development.
go mod tidy; gofmt -l . and go vet ./... clean.
Fix anything Go 1.27 vet flags (for example %w in Errorf inside the debug monitor at connect.go line 137 is passed to Errorf on the easymongo Logger, not fmt.Errorf, so it prints literally; switch to %v).
Replace interface{} with any where touched (not a global rewrite).
Implementation details
Commands, in order, from the repo root:
go mod edit -go=1.27
go mod edit -dropreplace=github.com/tophergopher/mongotest/v2 # if the temporary replace is present
go get github.com/tophergopher/mongotest/v2@<tagged version> go.mongodb.org/mongo-driver/v2@latest github.com/stretchr/testify@latest
go mod edit -droprequire=go.mongodb.org/mongo-driver -droprequire=github.com/tophergopher/mongotest -droprequire=docker.io/go-docker -droprequire=github.com/gogo/protobuf -droprequire=github.com/sirupsen/logrus
GOTOOLCHAIN=go1.27.1 go mod tidy
gofmt -l . ; go vet ./... ; go test -race ./...
Then delete the two commented // replace lines by hand (go mod edit does not remove comments).
Acceptance
go list -m all | wc -l is well below today's count (today's go.sum has 243 lines).
No replace directive in go.mod.
Full test suite green on Go 1.27.
Depends on: #2, #3, #4, #5, #6, #7, #8, #9 and the mongotest v2 module being tagged.
Part of the easymongo refactor (see
PLAN.mdon the refactor branch). Last code step, after the driver migration is complete.Working context (read this first)
github.com/tophergopher/easymongo. Start from branchclaude/mongotest-easymongo-refactor-wu2vhm; create a branchissue-<number>-<short-slug>from it and open a pull request back into it.PLAN.mdon that branch is the source of truth; read it before writing code.easymongotest/subpackage. The final toolchain target is Go 1.27 (set by Toolchain: go 1.27, latest dependencies, tidy, remove replace directives #10); any Go 1.24 or newer works until then. Before pushing:gofmt -l .prints nothing,go vet ./...,go test -race ./....*_test.goat the root, packageeasymongo_test, every test function callingsetup(t)fromcommon_test.go) is the regression net for this refactor. It must pass after your change. It needs a Docker daemon reachable through the normal Docker environment and themongo:8image.*mongo.Clienttype flows fromConnectiontoDatabasetoCollection), so the four driver issues Driver v2: migrate connect.go (mongo.Connect, Disconnect, BSONOptions, write concern) #2, Driver v2: options struct literals become builders; drop MaxTime; ArrayFilters and Delete option changes #3, Driver v2: primitive package merged into bson; replace x/bsonx in index.go #4 and Driver v2: Distinct returns a DistinctResult that must be decoded #5 land together in one pull request, worked in that order. Before them, New easymongotest subpackage wrapping mongotest/v2 #7 and Switch the easymongo test suite to easymongotest #8 must land so the test suite no longer depends on the oldgithub.com/tophergopher/mongotestv0.1.0 module (which itself imports easymongo and breaks the moment easymongo's types change). Until mongotest'sv2module is tagged, use a localreplace github.com/tophergopher/mongotest/v2 => ../mongotest/v2ingo.modand say so in the pull request; Toolchain: go 1.27, latest dependencies, tidy, remove replace directives #10 removes it.primitive.ObjectIDtobson.ObjectID), change only the types.Scope
go 1.27directive ingo.mod.go.mongodb.org/mongo-driver/v2(2.9.x or newer),github.com/stretchr/testify,github.com/tophergopher/mongotest/v2at its first tagged release. Removego.mongodb.org/mongo-driver(v1),docker.io/go-docker,github.com/gogo/protobuf,github.com/sirupsen/logrus,github.com/tophergopher/mongotest(v1 path).replacelines and any temporaryreplace ../mongotest/v2used during development.go mod tidy;gofmt -l .andgo vet ./...clean.%winErrorfinside the debug monitor atconnect.goline 137 is passed toErrorfon the easymongoLogger, notfmt.Errorf, so it prints literally; switch to%v).interface{}withanywhere touched (not a global rewrite).Implementation details
Commands, in order, from the repo root:
Then delete the two commented
// replacelines by hand (go mod editdoes not remove comments).Acceptance
go list -m all | wc -lis well below today's count (today'sgo.sumhas 243 lines).replacedirective ingo.mod.Depends on: #2, #3, #4, #5, #6, #7, #8, #9 and the mongotest
v2module being tagged.