本文整理匯總了Golang中launchpad/net/mgo.Session.Close方法的典型用法代碼示例。如果您正苦於以下問題:Golang Session.Close方法的具體用法?Golang Session.Close怎麽用?Golang Session.Close使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類launchpad/net/mgo.Session
的用法示例。
在下文中一共展示了Session.Close方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: createGobs
func createGobs(targetDir string) {
var makeGob = func(bmap interface{}, ptr interface{}) interface{} {
dbutil.BsonMapToObject(bmap, ptr)
return ptr
}
var makeAdminGob = func(bmap interface{}) interface{} {
return makeGob(bmap, &geoutil.GeoNamesAdminRecord{})
}
var makeNameGob = func(bmap interface{}) interface{} {
return makeGob(bmap, &geoutil.GeoNamesNameRecord{})
}
var makeZipGob = func(bmap interface{}) interface{} {
return makeGob(bmap, &geoutil.GeoNamesZipRecord{})
}
var lola numutil.Dvec2
var box [2][2]float64
var dbConn *mgo.Session
var dbName, fbName, fp string
var geoRecs []interface{}
dbutil.Panic = true
dbConn, _ = dbutil.ConnectToGlobal()
defer dbConn.Close()
dbName = dbutil.GeoNamesDbName(dbConn, true)
dbutil.FindAll(dbConn, dbName, "a", nil, &geoRecs)
gobutil.CreateGobsFile(path.Join(targetDir, "ga"), &geoRecs, makeAdminGob, true)
for lola.Y = geoutil.LatMin; lola.Y < geoutil.LatMax; lola.Y++ {
for lola.X = geoutil.LonMin; lola.X < geoutil.LonMax; lola.X++ {
fbName = geoutil.LoLaFileName(lola.X, lola.Y)
fmt.Println(fbName)
geoRecs = nil
box[0][0] = lola.X
box[0][1] = lola.Y
box[1][0] = lola.X + 1
box[1][1] = lola.Y + 1
dbutil.FindAll(dbConn, dbName, "n", bson.M{"l": bson.M{"$within": bson.M{"$box": box}}}, &geoRecs)
if len(geoRecs) == 0 {
geoRecs = nil
dbutil.FindOne(dbConn, dbName, "n", bson.M{"l": bson.M{"$near": []float64{lola.X + 0.5, lola.Y + 0.5}}}, &geoRecs)
}
fp = path.Join(path.Join(targetDir, "gn"), fbName)
fmt.Println(fp)
gobutil.CreateGobsFile(fp, &geoRecs, makeNameGob, true)
geoRecs = nil
dbutil.FindAll(dbConn, dbName, "z", bson.M{"l": bson.M{"$within": bson.M{"$box": box}}}, &geoRecs)
if len(geoRecs) > 0 {
fp = path.Join(path.Join(targetDir, "gz"), fbName)
fmt.Println(fp)
gobutil.CreateGobsFile(fp, &geoRecs, makeZipGob, true)
}
}
}
}