• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Golang db.Env类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中Wibo/db.Env的典型用法代码示例。如果您正苦于以下问题:Golang Env类的具体用法?Golang Env怎么用?Golang Env使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Env类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: main

func main() {
	Server := new(server.Server)
	myDb := new(db.Env)

	if len(os.Args) != 5 {
		fmt.Println("./Usage 'name bdd' 'pass bdd' 'user bdd' 'port bdd'")
		return
	}
	er := Server.InitServer()
	if er != nil {
		fmt.Println("Error on InitServer: ", er)
		return
	}
	Db, er := myDb.OpenCo(os.Args)
	if er != nil {
		Server.Logger.Println("OpenCo error: ", er)
		return
	}
	er = Server.Init_Data(myDb)
	if er != nil {
		Server.Logger.Println("Init_Data error: ", er)
		return
	}
	go ManageSignal(Server, myDb)
	go Manage_goroutines(Server, myDb)
	go sock.Listen(Server, Db)

	for {
		time.Sleep(time.Second * 60)
	}
}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:31,代码来源:main.go


示例2: SetFollowerBalls

func (Lstb *All_ball) SetFollowerBalls(curr_b *Ball, base *db.Env) {
	var idB int64
	base.Db.QueryRow("SELECT id FROM container WHERE ianix=$1;", curr_b.Id_ball).Scan(&idB)
	row, er := base.Db.Query("DELETE FROM followed WHERE container_id=$1", idB)
	if er != nil {
		Lstb.Logger.Println("Error on Delete followed: ", er)
	} else {
		defer row.Close()
	}
	for f := curr_b.Followers.Front(); f != nil; f = f.Next() {
		err := base.Transact(base.Db, func(tx *sql.Tx) error {
			stm, err := tx.Prepare("INSERT INTO followed(container_id, iduser) values($1,$2)")
			if err != nil {
				Lstb.Logger.Println(err)
				return err
			}
			defer stm.Close()
			_, err = stm.Exec(idB, f.Value.(*list.Element).Value.(*users.User).Id)
			if err != nil {
				Lstb.Logger.Println(err)
				return err
			}
			return nil
		})
		if err != nil {
			Lstb.Logger.Println(err)
		}
	}
}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:29,代码来源:update.go


示例3: addMessage

func (ball *Ball) addMessage(base *db.Env) error {
	var idB int64
	base.Db.QueryRow("SELECT id FROM container WHERE ianix=$1;", ball.Id_ball).Scan(&idB)
	idMessageMax, er := getIdMessageMax(idB, base)
	if er != nil {
		return er
	}
	for f := ball.Messages.Front(); f != nil; f = f.Next() {
		mes := f.Value.(Message)
		if mes.Id > idMessageMax {
			err := base.Transact(base.Db, func(tx *sql.Tx) error {
				stm, err := tx.Prepare("INSERT INTO message(content, containerid, index_m, size) VALUES ($1, (SELECT id FROM container WHERE ianix=$2), $3, $4)")
				if err != nil {
					return err
				}
				defer stm.Close()
				_, err = stm.Exec(strings.Trim(mes.Content, "\x00"), ball.Id_ball, f.Value.(Message).Id, f.Value.(Message).Size)
				return err
			})
			if err != nil {
				return er
			}
		}
	}
	return nil
}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:26,代码来源:update.go


示例4: UpdateLocation

func (b *Ball) UpdateLocation(base *db.Env) error {
	var idB int64
	base.Db.QueryRow("SELECT id FROM container WHERE ianix=$1;", b.Id_ball).Scan(&idB)
	id := int64(0)
	if b.Possessed != nil {
		id = b.Possessed.Value.(*users.User).Id
	}

	err := base.Transact(base.Db, func(tx *sql.Tx) error {
		stm, err := tx.Prepare(" SELECT setdatacontainer($1, $2, $3, $4, $5, $6, $7, $8)")
		if err != nil {
			return err
		}
		defer stm.Close()
		_, err = stm.Exec(b.Wind.Degress, b.Wind.Speed, b.Coord.Value.(Checkpoint).Coord.Lat, b.Coord.Value.(Checkpoint).Coord.Lon, idB, id, b.Coord.Value.(Checkpoint).Date, b.Coord.Value.(Checkpoint).MagnetFlag)
		if err != nil {
			return err
		}
		return nil
	})
	if err != nil {
		return err
	}
	return nil
}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:25,代码来源:update.go


示例5: TestUsers

func TestUsers(t *testing.T) {

	var err error
	Lst_users := new(users.All_users)
	Lst_ball := new(ballon.All_ball)
	myDb := new(db.Env)
	Lst_users.Ulist = list.New()
	Lst_ball.Blist = list.New()
	Db, err := myDb.OpenCo(err)
	user1 := new(users.User)
	user1.Mail = "[email protected]"
	user1.Log = time.Now()
	user1.Followed = list.New()
	user1.Stats = &users.StatsUser{}
	user1.Stats.CreationDate = time.Now()
	user1.Coord.Lat = 48.833086
	user1.Coord.Lon = 2.316055
	user1.Log = time.Now()
	Lst_users.Ulist.PushBack(user1)

	fmt.Println(result)
}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:22,代码来源:users_test.go


示例6: InsertMessages

func (Lst_ball *All_ball) InsertMessages(messages *list.List, idBall int64, base *db.Env) (err error) {
	i := 0
	for e := messages.Front(); e != nil; e = e.Next() {
		err = base.Transact(base.Db, func(tx *sql.Tx) error {
			stm, err := tx.Prepare("INSERT INTO message(content, containerid, index_m, size) VALUES ($1, $2, $3, $4)")
			if err != nil {
				Lst_ball.Logger.Println("Erreur tx prepare: ", err)
				return err
			}
			defer stm.Close()
			row, err := stm.Query(sanit.Accents(strings.Trim(e.Value.(Message).Content, "\x00")), idBall, i, e.Value.(Message).Size)
			if err != nil {
				Lst_ball.Logger.Println("Erreur Query: ", err)
				return err
			}
			defer row.Close()
			i++
			return err
		})
	}
	return nil
}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:22,代码来源:update.go


示例7: TestBallon

func TestBallon(t *testing.T) {

	var err error

	Lst_users := new(users.All_users)
	Lst_ball := new(ballon.All_ball)
	myDb := new(db.Env)
	Lst_users.Ulist = list.New()
	Lst_ball.Blist = list.New()
	Db, err := myDb.OpenCo(err)
	Lst_ball.Get_balls(Lst_users, myDb)
	fmt.Println(Db)

	user1 := new(users.User)
	user1.Id = 125
	user1.Mail = "[email protected]"
	user1.Log = time.Now()
	user1.Followed = list.New()
	user1.Stats = &users.StatsUser{}
	user1.Stats.CreationDate = time.Now()
	user1.Coord.Lat = 48.833086
	user1.Coord.Lon = 2.316055
	user1.Log = time.Now()
	Lst_users.Ulist.PushBack(user1)

	createBall1000(Lst_ball, Lst_users.Ulist.Front(), myDb)
	/* CREER UN BALLON POUR FAIRE DES TESTS */

	// tmp_lst := list.New()
	// var check_test0 ballon.Checkpoint
	// check_test0.Coord.Lon = 48.833086
	// check_test0.Coord.Lat = 2.316055
	// check_test0.Date = time.Now()

	// var check_test1 ballon.Checkpoint
	// check_test1.Coord.Lon = 48.833586
	// check_test1.Coord.Lat = 2.316065
	// check_test1.Date = time.Now()

	// var check_test2 ballon.Checkpoint
	// check_test2.Coord.Lon = 48.833368
	// check_test2.Coord.Lat = 2.316059
	// check_test2.Date = time.Now()

	// var check_test3 ballon.Checkpoint
	// check_test3.Coord.Lon = 48.833286
	// check_test3.Coord.Lat = 2.316903
	// check_test3.Date = time.Now()

	// var check_test4 ballon.Checkpoint
	// check_test4.Coord.Lon = 48.833986
	// check_test4.Coord.Lat = 2.316045
	// check_test4.Date = time.Now()

	// lmessages := list.New()
	// listMessage1 := list.New()
	// var message0 ballon.Message
	// message0.Id = 0
	// message0.Size = 68
	// message0.Content = "Mensaje 1 test"
	// message0.Type = 1
	// var message1 ballon.Message
	// message1.Id = 0
	// message1.Size = 68
	// message1.Content = "Mensaje 2 test"
	// message1.Type = 1
	// var message2 ballon.Message
	// message2.Id = 2
	// message2.Size = 68
	// message2.Content = "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean com"
	// message2.Type = 1

	// listMessage1.PushBack(message0)
	// lmessages.PushBack(message0)
	// lmessages.PushBack(message1)
	// lmessages.PushBack(message2)

	// ball0 := new(ballon.Ball)
	// ball0.Id_ball = 45
	// ball0.Title = "toto"
	// ball0.Coord = tmp_lst.PushBack(check_test0)
	// ball0.Wind = ballon.Wind{}
	// ball0.Messages = listMessage1
	// ball0.Date = time.Now()
	// ball0.Checkpoints = list.New()
	// ball0.Possessed = nil
	// ball0.Followers = list.New()
	// ball0.Creator = nil
	// Lst_ball.Blist.PushBack(ball0)

	// ball1 := new(ballon.Ball)
	// ball1.Id_ball = 1
	// ball1.Title = "tata"
	// ball1.Coord = tmp_lst.PushBack(check_test1)
	// ball1.Wind = ballon.Wind{}
	// ball1.Messages = listMessage1
	// ball1.Date = time.Now()
	// ball1.Checkpoints = list.New()
	// ball1.Possessed = nil
	// ball1.Followers = list.New()
//.........这里部分代码省略.........
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:101,代码来源:ballon_test.go


示例8: TestBallon

func TestBallon(t *testing.T) {

	var err error

	Lst_users := new(users.All_users)
	Lst_ball := new(ballon.All_ball)
	Lprotocol := new(protocol.Request)
	Ldevices := new(devices.All_Devices)
	myDb := new(db.Env)
	Lst_users.Ulist = list.New()
	Lst_ball.Blist = list.New()
	Db, err := myDb.OpenCo(err)
	Lst_ball.Get_balls(Lst_users, myDb)
	fmt.Println(Db)

	Lprotocol.Coord.Lon = 48.833986
	Lprotocol.Coord.Lat = 2.316045
	// user1 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user2 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user3 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user4 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user5 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user6 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user7 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "[email protected]"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()

	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	Lst_users.Get_users(myDb.Db)
	Ldevices.Get_devices(Lst_users, myDb)

}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:62,代码来源:devices_test.go


示例9: GetListBallsByUser

func (Lb *All_ball) GetListBallsByUser(userE *list.Element, base *db.Env, Ulist *list.List) (lBallon *list.List, err error) {
	lBallon = list.New()
	err = nil

	err = base.Transact(base.Db, func(tx *sql.Tx) error {
		var errT error
		stm, errT := tx.Prepare("SELECT getcontainersbyuserid($1);")
		if errT != nil {
			Lb.Logger.Println(errT)
			return errT
		}
		defer stm.Close()
		rows, errT := stm.Query(userE.Value.(*users.User).Id)
		if errT != nil {
			Lb.Logger.Println(err)
			return errT
		}
		defer rows.Close()
		for rows.Next() {
			var infoCont string
			errT = rows.Scan(&infoCont)
			if errT != nil {
				Lb.Logger.Println(err)
				return errT
			}
			result := strings.Split(infoCont, ",")

			idBall := GetIdBall(result[0])
			magnet, _ := strconv.Atoi(result[8])
			tempCord := Lb.getExtraInfo(result[6], Lb.GetDateFormat(result[9]), int16(magnet))
			lstIt := list.New()
			sStat, errT := Lb.GetStatsBallon(int64(idBall), base.Db)
			if errT != nil {
				Lb.Logger.Println("GetStatsBallon: ", errT)
				return errT
			}
			possessed, errT := GetWhomGotBall(idBall, Ulist, base.Db)
			if errT != nil {
				Lb.Logger.Println("GetWhomGotBall error: ", errT)
				return errT
			}
			tmpBall := Lb.Get_ballbyid(GetIdBall(result[7]))
			if tmpBall != nil {
				// Do Nothing
			} else {
				lstMess, errT := Lb.GetMessagesBall(idBall, base.Db)
				if errT != nil {
					Lb.Logger.Println("GetMessageBall error: ", errT)
					return errT
				}
				lstFols, errT := Lb.GetFollowers(idBall, base.Db, Ulist)
				if errT != nil {
					Lb.Logger.Println("GetFollowers error: ", errT)
					return errT
				}
				tr := '"'
				lBallon.PushBack(
					&Ball{
						Id_ball:     GetIdBall(result[7]),
						Title:       strings.Trim(result[1], string(tr)),
						Date:        Lb.GetDateFormat(result[5]),
						Checkpoints: list.New(),
						Itinerary:   lstIt,
						Scoord:      tempCord.Front(),
						Coord:       tempCord.Front(),
						Wind:        GetWin(result[3], result[4]),
						Messages:    lstMess,
						Followers:   lstFols,
						Possessed:   possessed,
						Stats:       sStat,
						Creator:     userE})
			}
		}
		return errT
	})
	if err != nil {
		return nil, err
	}
	return lBallon, nil

}
开发者ID:42MrPiou42,项目名称:Wibo_OpenProject,代码行数:81,代码来源:ballon.go



注:本文中的Wibo/db.Env类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang worker.Tuple类代码示例发布时间:2022-05-28
下一篇:
Golang util.HttpResponse类代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap