1. package main
    2. import "fmt"
    3. func main() {
    4. i := 1
    5. for ; i <= 10; i++ {
    6. fmt.Println("hello", i)
    7. }
    8. fmt.Println("i的最后的值是:", i)
    9. }

    输出内容为:

    1. hello 1
    2. hello 2
    3. hello 3
    4. hello 4
    5. hello 5
    6. hello 6
    7. hello 7
    8. hello 8
    9. hello 9
    10. hello 10
    11. i的最后的值是: 11