This commit is contained in:
chai2010
2015-12-09 15:57:17 +08:00
commit 3b8de6c274
392 changed files with 313028 additions and 0 deletions

29
vendor/gopl.io/ch8/countdown1/countdown.go generated vendored Normal file
View File

@@ -0,0 +1,29 @@
// Copyright © 2016 Alan A. A. Donovan & Brian W. Kernighan.
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
// See page 244.
// Countdown implements the countdown for a rocket launch.
package main
import (
"fmt"
"time"
)
//!+
func main() {
fmt.Println("Commencing countdown.")
tick := time.Tick(1 * time.Second)
for countdown := 10; countdown > 0; countdown-- {
fmt.Println(countdown)
<-tick
}
launch()
}
//!-
func launch() {
fmt.Println("Lift off!")
}