Background
I find that go.mongodb.org/mongo-driver and github.com/mongodb/mongo-go-driver coexist in this repo:
https://github.com/longfellowone/field-services/blob/master/go.mod (Line 22 & 32)
github.com/mongodb/mongo-go-driver v1.0.1
go.mongodb.org/mongo-driver v1.0.1 // indirect
That’s because the mongodb/mongo-go-driver has already renamed it’s import path from "github.com/mongodb/mongo-go-driver" to "go.mongodb.org/mongo-driver". When you use the old path "github.com/mongodb/mongo-go-driver" to import the mongodb/mongo-go-driver, will reintroduces mongodb/mongo-go-driver through the import statements "import go.mongodb.org/mongo-driver" in the go source file of mongodb/mongo-go-driver.
https://github.com/mongodb/mongo-go-driver/blob/v1.0.1/mongo/client.go#L16
package mongo
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/bson/bsoncodec"
…
)
The "go.mongodb.org/mongo-driver" and "github.com/mongodb/mongo-go-driver" are the same repos. This will work in isolation, bring about potential risks and problems.
Solution
Follow the requirements of mongodb/mongo-go-driver README.md:
To get started with the driver, import the mongo package, create a mongo.Client:
import (
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)
…
Replace all the old import paths, change "github.com/mongodb/mongo-go-driver" to "go.mongodb.org/mongo-driver".
Where did you import it: https://github.com/longfellowone/field-services/search?q=github.com%2Fmongodb%2Fmongo-go-driver&unscoped_q=github.com%2Fmongodb%2Fmongo-go-driver
Background
I find that
go.mongodb.org/mongo-driverandgithub.com/mongodb/mongo-go-drivercoexist in this repo:https://github.com/longfellowone/field-services/blob/master/go.mod (Line 22 & 32)
That’s because the
mongodb/mongo-go-driverhas already renamed it’s import path from "github.com/mongodb/mongo-go-driver" to "go.mongodb.org/mongo-driver". When you use the old path "github.com/mongodb/mongo-go-driver" to import themongodb/mongo-go-driver, will reintroducesmongodb/mongo-go-driverthrough the import statements "import go.mongodb.org/mongo-driver" in the go source file ofmongodb/mongo-go-driver.https://github.com/mongodb/mongo-go-driver/blob/v1.0.1/mongo/client.go#L16
The "go.mongodb.org/mongo-driver" and "github.com/mongodb/mongo-go-driver" are the same repos. This will work in isolation, bring about potential risks and problems.
Solution
Follow the requirements of mongodb/mongo-go-driver README.md:
Replace all the old import paths, change
"github.com/mongodb/mongo-go-driver"to"go.mongodb.org/mongo-driver".Where did you import it: https://github.com/longfellowone/field-services/search?q=github.com%2Fmongodb%2Fmongo-go-driver&unscoped_q=github.com%2Fmongodb%2Fmongo-go-driver