Whenever you want to persist data in a MongoDB database, the first step you have to take is to establish a connection between the database and your web application, which we will be covering in this recipe using one of the most famous and commonly used MongoDB drivers for Go - gopkg.in/mgo.v2.
Integrating MongoDB and Go
Getting ready...
Verify whether MongoDB is installed and running locally on port 27017 by executing the following command:
$ mongo
This should return the following response:
How to do it...
- Install the gopkg.in/mgo.v package, using the go get command...