exit with err if cancelled and newline
parent
d7d888453b
commit
5f38a36027
11
main.go
11
main.go
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in New Issue