gofmt
This commit is contained in:
parent
785a0d123b
commit
b2bae182ee
@ -2,32 +2,32 @@
|
|||||||
|
|
||||||
// `for` is Go's only looping construct. Here are
|
// `for` is Go's only looping construct. Here are
|
||||||
// two common forms.
|
// two common forms.
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import "fmt"
|
import "fmt"
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
|
||||||
// Initialize `i` with `1` and loop until it's 10.
|
// Initialize `i` with `1` and loop until it's 10.
|
||||||
i := 1
|
i := 1
|
||||||
for i <= 3 {
|
for i <= 3 {
|
||||||
fmt.Print(i)
|
fmt.Print(i)
|
||||||
i = i + 1
|
i = i + 1
|
||||||
}
|
}
|
||||||
|
|
||||||
// That type of loop is common. We can do it on one
|
// That type of loop is common. We can do it on one
|
||||||
// line.
|
// line.
|
||||||
for j := 1; j <= 3; j++ {
|
for j := 1; j <= 3; j++ {
|
||||||
fmt.Print(j)
|
fmt.Print(j)
|
||||||
}
|
}
|
||||||
|
|
||||||
// `for` without a condition will loop until you
|
// `for` without a condition will loop until you
|
||||||
// `return`.
|
// `return`.
|
||||||
for {
|
for {
|
||||||
fmt.Println()
|
fmt.Println()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// We'll see other `for` forms latter.
|
// We'll see other `for` forms latter.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user