// Homework 39, problem 3: A countdown you can stop. // // Count down from 5 to 1, one number per second, then print "Liftoff!" Use a // time.NewTicker for the beat. If the user presses Ctrl+C during the // countdown, print "Countdown stopped at N." and end, where N is the last // number shown. Use signal.NotifyContext. // // Run with: go run exercises/39/homework/03-countdown.go package main import ( "fmt" "time" ) func main() { // TODO: make the context with signal.NotifyContext, and a ticker, and // use select in place of time.Sleep. for n := 5; n >= 1; n-- { fmt.Println(n) time.Sleep(time.Second) } fmt.Println("Liftoff!") }