0

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.

Tim
  • 1
  • 141
  • 372
  • 590

2 Answers2

2

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.

Charlie Tumahai
  • 113,709
  • 12
  • 249
  • 242
1

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.

Simone Carletti
  • 173,507
  • 49
  • 363
  • 364
  • thanks. does `v2` in `labix.org/v2/mgo` mean version 2 or 1 of the driver? – Tim Jul 20 '16 at 17:49
  • I'm not sure. Actually, I've just noticed `gopkg.in` is actually a version-aware redirector. Hence, it's even possible that in reality `gopkg.in/mgo.v2` is an alias for the labix.org path. I'd use `gopkg.in/mgo.v2` in any case. – Simone Carletti Jul 20 '16 at 17:51