diff --git a/main.go b/main.go index 4907e1e..7a82031 100644 --- a/main.go +++ b/main.go @@ -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):