lock to ensure email finishes call
parent
3d76fffdd3
commit
70f15434ff
7
main.go
7
main.go
|
|
@ -11,25 +11,28 @@ import (
|
|||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var stateFinder = regexp.MustCompile(`[ ^>][A-Z][A-Z][ $<]`)
|
||||
|
||||
func main() {
|
||||
lock := &sync.Mutex{}
|
||||
go func() {
|
||||
email()
|
||||
c := time.NewTicker(time.Minute)
|
||||
for range c.C {
|
||||
lock.Lock()
|
||||
if err := email(); err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
lock.Unlock()
|
||||
}
|
||||
}()
|
||||
if err := _main(); err != nil {
|
||||
panic(err)
|
||||
}
|
||||
time.Sleep(time.Minute)
|
||||
lock.Lock()
|
||||
}
|
||||
|
||||
func email() error {
|
||||
|
|
|
|||
Loading…
Reference in New Issue