Using the MongoDB Go driver

In order to use MongoDB in your Go programs, you should first have the MongoDB Go driver installed on your Unix machine. The name of the MongoDB Go driver is mgo and you can learn more information about the MongoDB Go driver by visiting https://github.com/go-mgo/mgo, https://labix.org/mgo, and https://docs.mongodb.com/ecosystem/drivers/go/.

As the driver is not part of the standard Go library, you should first download the required packages using the following two commands:

$ go get labix.org/v2/mgo
$ go get labix.org/v2/mgo/bson

After that, you will be free to use it in your own Go utilities. If you try to execute the program without having the two packages on your Unix system, you will get an error message similar ...

Get Go Systems Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.