Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // na base
- func main() {
- // conexao
- Db := Conn.Connet()
- // Exemplo 1
- // posso fazer milhares de
- // chamadas e ele retorna sempre
- // a instancia que esta em memoria
- go func() {
- for i := 0; i < 10000000; i++ {
- Db = Conn.Connet()
- fmt.Println("Goroutine1 Connect: ", i)
- time.Sleep(time.Millisecond * 50)
- }
- }()
- // Exemplo 2
- // criando 200 goroutines
- for x := 0; x < 200; x++ {
- go func(x int) {
- for j := 0; j < 10000; j++ {
- fmt.Printf("Goroutine2 Connect: %d -> %d", x, j)
- fmt.Printf(" login: %s", Conn.Connet().GetUserEmail(x))
- time.Sleep(time.Millisecond * 150)
- }
- }(x)
- }
- fmt.Scanln()
- }
Add Comment
Please, Sign In to add comment