What simple way for change used driver

Hello, I with my team use old mongo driver GitHub - globalsign/mgo: The MongoDB driver for Go and we want to change them to official driver go.mongodb.org/mongo-driver.

This drivers (ofcourse) have a different types, and we can’t use both of them. Maybe exists fork in github with adapter from old to new driver.

We cannot rewrite all requests, because it will take a month or more to work. (We really have large number of requests)

Thank you for help!

The company I am working for now faced the same issue.

What we did was have both the mongo drivers installed (mgo and go-mongo-driver). All the newer APIs were re-written to the official mongo driver by the import alias method. Then we gradually re-wrote the existing APIs to the official driver.

The below post was of great help during the migration process:

Unfortunately, there is no straightforward way built-in way of doing this (at least none that I am aware of).

3 Likes

Thank you for your help it was usefull.
I asked this question in mongo-driver jira board and in reply they send to me link to package. This package handle bson from mgo: mgocompat package - go.mongodb.org/mongo-driver/bson/mgocompat - Go Packages
I just set this property to connect and problems with unmushal to mgo bson was resolved.
Simple example usage:
connOpt := options.Client().SetRegistry(mgocompat.Registry)

1 Like

Thanks a lot for the info.

This is a piece of much-needed information.

1 Like

This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.