exit with err if cancelled and newline

main
Bel LaPointe 2025-05-14 09:15:37 -04:00
parent d7d888453b
commit 5f38a36027
1 changed files with 11 additions and 0 deletions

11
main.go
View File

@ -34,9 +34,19 @@ func main() {
}
for alert := range alerts {
if ctx.Err() != nil {
break
}
if err := alertAt(ctx, *ntfy, time.Now(), alert, time.Now().Format("15:04")); err != nil && ctx.Err() == nil {
panic(err)
}
if ctx.Err() != nil {
break
}
}
if err := ctx.Err(); err != nil {
os.Exit(1)
}
}
@ -64,6 +74,7 @@ func alertsAfter(ctx context.Context, dur time.Duration) (chan string, error) {
case <-time.After(time.Second):
}
}
fmt.Println()
ch <- "alerting after " + dur.String()
}()
return ch, nil