only enough

main
Bel LaPointe 2025-10-03 13:47:33 -06:00
parent d17993453e
commit cf9f50f583
1 changed files with 9 additions and 1 deletions

10
main.go
View File

@ -70,9 +70,17 @@ func alertsAfter(ctx context.Context, dur time.Duration, msg string) (chan strin
deadline := time.Now().Add(dur)
go func() {
defer close(ch)
var prev string
for ctx.Err() == nil && time.Now().Before(deadline) {
seconds := int(time.Until(deadline).Seconds())
fmt.Printf("\r%v ", time.Duration(seconds)*time.Second)
cur := fmt.Sprintf("%v", time.Duration(seconds)*time.Second)
if prev != "" {
fmt.Printf("\r%s\r", strings.Repeat(" ", len(prev)))
}
fmt.Printf("%s", cur)
prev = cur
select {
case <-ctx.Done():
case <-time.After(time.Second):