Merge pull request #319 from appleboy/patch-5

fix: coding style and file format for chapter 8.
This commit is contained in:
无闻
2017-02-10 23:31:27 -05:00
committed by GitHub
2 changed files with 110 additions and 108 deletions

View File

@@ -5,13 +5,13 @@ import (
"fmt" "fmt"
) )
var Days = map[int]string{1:"monday", var Days = map[int]string{1: "monday",
2:"tuesday", 2: "tuesday",
3: "wednesday", 3: "wednesday",
4: "thursday", 4: "thursday",
5: "friday", 5: "friday",
6: "saturday", 6: "saturday",
7: "sunday"} 7: "sunday"}
func main() { func main() {
fmt.Println(Days) fmt.Println(Days)
@@ -19,7 +19,7 @@ func main() {
flagHolliday := false flagHolliday := false
for k, v := range Days { for k, v := range Days {
if v == "thursday" || v == "holliday" { if v == "thursday" || v == "holliday" {
fmt.Println(v, " is the ", k , "th day in the week") fmt.Println(v, " is the ", k, "th day in the week")
if v == "holliday" { if v == "holliday" {
flagHolliday = true flagHolliday = true
} }
@@ -29,6 +29,7 @@ func main() {
fmt.Println("holliday is not a day!") fmt.Println("holliday is not a day!")
} }
} }
/* Output: /* Output:
thursday is the 4 th day in the week thursday is the 4 th day in the week
holliday is not a day! holliday is not a day!

View File

@@ -8,11 +8,11 @@ import (
func main() { func main() {
drinks := map[string]string{ drinks := map[string]string{
"beer": "bière", "beer": "bière",
"wine": "vin", "wine": "vin",
"water": "eau", "water": "eau",
"coffee": "café", "coffee": "café",
"thea": "thé"} "thea": "thé"}
sdrinks := make([]string, len(drinks)) sdrinks := make([]string, len(drinks))
ix := 0 ix := 0
@@ -43,6 +43,7 @@ func main() {
fmt.Printf("The french for %s is %s\n", eng, drinks[eng]) fmt.Printf("The french for %s is %s\n", eng, drinks[eng])
} }
} }
/* Output: /* Output:
The following drinks are available: The following drinks are available:
wine wine