Golang之使用mgo连接MongoDB

session, err := mgo.Dial("localhost:27017") 
if err != nil { 
     log.Println("err: ", err) 
     return 
} 
defer session.Close() 
// Optional. Switch the session to a monotonic behavior. 
session.SetMode(mgo.Monotonic, true) 
c := session.DB("logs").C("log_event")
发布了204 篇原创文章 · 获赞 59 · 访问量 14万+

猜你喜欢

转载自blog.csdn.net/baidu_34122324/article/details/102525267
mgo
今日推荐