var GlobalMongoDB *mgo.Database func NewConnection(MY_HOST, MY_DB, USER, PASS) { session, _ := mgo.Dial(MY_HOST) session.SetMode(mgo.Monotonic, true) db := session.DB(MY_DB) db.Login(USER, PASS) return db }
func init() {
GlobalMongoDB = NewConnection(MY_HOST, MY_DB, USER, PASS)
}
2. Call NewConnection every time I need connection the the database
--
You received this message because you are subscribed to the Google Groups "mgo-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mgo-users+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.