mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:21:38 +08:00
fix: coding style and file format for all example.
This commit is contained in:
@@ -1,31 +1,32 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
seasons := []string{"Spring","Summer","Autumn","Winter"}
|
||||
|
||||
for ix, season := range seasons {
|
||||
fmt.Printf("Season %d is: %s\n", ix, season)
|
||||
}
|
||||
|
||||
var season string
|
||||
for _, season = range seasons {
|
||||
fmt.Printf("%s\n", season)
|
||||
}
|
||||
|
||||
for ix := range seasons {
|
||||
fmt.Printf("%d ", ix)
|
||||
}
|
||||
}
|
||||
/* Output:
|
||||
Season 0 is: Spring
|
||||
Season 1 is: Summer
|
||||
Season 2 is: Autumn
|
||||
Season 3 is: Winter
|
||||
Spring
|
||||
Summer
|
||||
Autumn
|
||||
Winter
|
||||
0 1 2 3
|
||||
*/
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
seasons := []string{"Spring", "Summer", "Autumn", "Winter"}
|
||||
|
||||
for ix, season := range seasons {
|
||||
fmt.Printf("Season %d is: %s\n", ix, season)
|
||||
}
|
||||
|
||||
var season string
|
||||
for _, season = range seasons {
|
||||
fmt.Printf("%s\n", season)
|
||||
}
|
||||
|
||||
for ix := range seasons {
|
||||
fmt.Printf("%d ", ix)
|
||||
}
|
||||
}
|
||||
|
||||
/* Output:
|
||||
Season 0 is: Spring
|
||||
Season 1 is: Summer
|
||||
Season 2 is: Autumn
|
||||
Season 3 is: Winter
|
||||
Spring
|
||||
Summer
|
||||
Autumn
|
||||
Winter
|
||||
0 1 2 3
|
||||
*/
|
||||
|
Reference in New Issue
Block a user