Reputation: 11
I am trying to establish connection with mongoDB using the below code
func getSession() \*mgo.Session {
// Connect to MongoDB on the default port
s, err := mgo.Dial("mongodb://localhost:27017")
if err != nil {
log.Fatal("Failed to connect to MongoDB: ", err)
}
return s
}
MongoDb is running on port 27017. I am using "gopkg.in/mgo.v2". Please help
I have verified the connection for mongoDB and its running on the default port.
Upvotes: 1
Views: 86