lock to ensure email finishes call

master
Bel LaPointe 2022-01-10 00:23:39 -05:00
parent 3d76fffdd3
commit 70f15434ff
1 changed files with 5 additions and 2 deletions

View File

@ -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 {