package main
import (
"fmt"
"time"
)
func countdown(seconds int) {
fmt.Printf("Total time: %d seconds\n", seconds)
for seconds > 0 {
time.Sleep(1 * time.Second) // Sleep for 1 second
seconds--
fmt.Printf("Time remaining: %d seconds\n", seconds)
}
}
func main() {
sec := 5
countdown(sec)
}
/*
run:
Total time: 5 seconds
Time remaining: 4 seconds
Time remaining: 3 seconds
Time remaining: 2 seconds
Time remaining: 1 seconds
Time remaining: 0 seconds
*/