Dears,
Hi,
I have a question regarding the MongoDB package for Go (mgo).
I have installed MongoDB and confirmed that it is running. However, when I
try to connect to it using Go, I consistently get the following error: *"No
reachable servers"*
I would appreciate any guidance on how to resolve this issue.
Best,
Semia
package main
import (
"fmt"
"log"
"gopkg.in/mgo.v2"
)
func main() {
fmt.Println("Attempting to connect to MongoDB...")
session, err := mgo.Dial("mongodb://localhost:27017")
if err != nil {
log.Fatal("MongoDB connection failed: ", err)
}
defer session.Close()
fmt.Println("MongoDB connected successfully!")
}
--
--
You received this message because you are subscribed to the Google Groups
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion visit
https://groups.google.com/d/msgid/golang-nuts/b7e7c5c9-700d-44b9-a46c-e7b64a4fadcdn%40googlegroups.com.