1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| package main
import ( "fmt" )
func ForDemo1() { for i:=1; i<=5 ; i++ { fmt.Println("-->", i) } }
func ForDemo2() { var i int for i <= 5 { fmt.Println("--->", i) i++ } }
func ForDemo3() { for { fmt.Println("这是个死循环") } }
func main() { ForDemo1() ForDemo2() ForDemo3() }
|