only enough
This commit is contained in:
10
main.go
10
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):
|
||||
|
||||
Reference in New Issue
Block a user