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.
New contributor
Ravi is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.