I have found two places of the mongodb driver in Go
Are they the same distribution and version of mongodb driver in Go?
Why are there two pathnames for the same package?
Which one of the two shall I use?
Thanks.
You can find more information in the official page. The page links
gopkg.in/mgo.v2
From what I can see, labix.org/v2/mgo
is probably the version 1 of the driver, whereas gopkg.in/mgo.v2
is the new version.
Go doesn't have traditional package distribution or versioning. Therefore, if you need a major refactoring and you want to break backward-compatibility, a common approach is to publish a different version at a different path.
I guess that's what happened here.
The package labix.org/v2/mgo was moved to gopkg.in/mgo.v2 according to a commit in the gopkg.in/mgo.v2 source.
The author of mgo also created gopkg.in. He moved several of his packages from his "vanity" path on labix.org to gopkg.in.
The source for labix.org/v2/mgo is at http://bazaar.launchpad.net/+branch/mgo/v2/files/head:/. The most recent update is July 1, 2014.
The source for gopkg.in/mgo.v2 is at https://github.com/go-mgo/mgo/tree/v2. This tree is a continuation of bazaar.launchpad.net/+branch/mgo/v2. The most recent update is June 9, 2016.
Use gopkg.in/mgo.v2.