-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
167 lines (157 loc) · 2.79 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
package main
import (
"encoding/json"
"fmt"
r "mas/db"
)
func main() {
guestRepo := r.GuestRepo{}
guestFilter := r.NewGuestFilter()
guestFilter.Country = "us"
guests, totals, _ := guestRepo.Get(guestFilter)
//fmt.Println(guests)
b, _ := json.Marshal(guests)
fmt.Printf("Totals: %d \n", totals)
fmt.Println(string(b))
//for _, val := range all {
// fmt.Println(string(json.Marshal(val)))
//}
}
//// package main
//
//// import (
//// "fmt"
//
//// "./repository"
//// )
//
//// type Salutation struct {
//// name string
//// greeting string
//// times int
//// }
//
//// type Salutations []Salutation
//
//// type Printer func(string)
//
//// func (salutations Salutations) Greet(do Printer, isFormal bool, times int) {
//// for _, s := range salutations {
//// fmt.Println(s.name)
//// }
//// }
//
//// func (salutations Salutations) ChannelGreeter(c chan Salutation) {
//// for _, s := range salutations {
//// c <- s
//// }
//// close(c)
//// }
//
//// func main() {
//// repository.InitDB("root", "", "127.0.0.1")
//
//// salutations := Salutations{
//// {"lol", "ek", 1},
//// {"kal", "el", 2},
//// {"super", "mman", 3},
//// }
//
//// c := make(chan Salutation)
//// c2 := make(chan Salutation)
//
//// go salutations.ChannelGreeter(c)
//// go salutations.ChannelGreeter(c2)
//
//// for {
//// select {
//// case s, ok := <-c:
//// if ok {
//// fmt.Println(s, 1)
//// } else {
//// return
//// }
//
//// case s, ok := <-c:
//// if ok {
//// fmt.Println(s, 2)
//// } else {
//// return
//// }
//
//// default:
//// fmt.Println("default")
//// }
//
//// }
//// }
//
//package main
//
//import (
// "fmt"
//
// "./repository"
//)
//
//type Salutation struct {
// name string
// greeting string
// times int
//}
//
//type Salutations []Salutation
//
//type Printer func(string)
//
//func (salutations Salutations) Greet(do Printer, isFormal bool, times int) {
// for _, s := range salutations {
// fmt.Println(s.name)
// }
//}
//
//func (salutations Salutations) ChannelGreeter(c chan Salutation) {
// for _, s := range salutations {
// c <- s
// }
// close(c)
//}
//
//func main() {
// repository.InitDB("root", "", "127.0.0.1")
// doSequential()
// doConcurrent()
//}
//
//func doSequential() {
// allGuests, _ := repository.GetAllGuests()
// allBooks, _ := repository.GetAll()
//
// fmt.Println("LenBooks", len(allBooks))
// fmt.Println("LenGuests", len(allGuests))
//
//}
//
//func doConcurrent() {
// c := make(chan bool, 2)
//
// go getBooks(c)
// go func() {
// allGuests, _ := repository.GetAllGuests()
//
// fmt.Println("LenGuests", len(allGuests))
//
// c <- true
// }()
//
// <-c
// <-c
//}
//
//func getBooks(c chan){
// allBooks, _ := repository.GetAll()
//
// fmt.Println("LenBooks", len(allBooks))
//
// c <- true
//}