-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
48 lines (45 loc) · 1.02 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
package main
import (
"demoapp/notify"
"log"
"net/http"
_ "net/http/pprof"
"sync"
)
func main() {
emailnotidy := notify.NewEailNotidy()
// not working tcp out of order
http.HandleFunc("/send", func(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("send email"))
wg := sync.WaitGroup{}
wg.Add(2)
for i := 0; i < 2; i++ {
go func(wg *sync.WaitGroup) {
defer wg.Done()
err := emailnotidy.Send("[email protected]", "demoapp", map[string]interface{}{
"content": "dalongdemoapp",
})
if err != nil {
log.Println("err:", err.Error())
}
}(&wg)
}
wg.Wait()
})
http.HandleFunc("/send2", func(res http.ResponseWriter, req *http.Request) {
res.Write([]byte("send email"))
for _, to := range []string{
} {
err := emailnotidy.Send(to, "demoapp", map[string]interface{}{
"content": "dalongdemoapp",
})
if err != nil {
log.Println("err:", err.Error())
}
}
})
http.ListenAndServe(":9090", nil)
}