mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-11 22:06:51 +08:00
35 lines
662 B
Go
Executable File
35 lines
662 B
Go
Executable File
// map_days.go
|
|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
)
|
|
|
|
var Days = map[int]string{1:"monday",
|
|
2:"tuesday",
|
|
3: "wednesday",
|
|
4: "thursday",
|
|
5: "friday",
|
|
6: "saturday",
|
|
7: "sunday"}
|
|
|
|
func main() {
|
|
fmt.Println(Days)
|
|
// fmt.Printf("%v", Days)
|
|
flagHolliday := false
|
|
for k, v := range Days {
|
|
if v == "thursday" || v == "holliday" {
|
|
fmt.Println(v, " is the ", k , "th day in the week")
|
|
if v == "holliday" {
|
|
flagHolliday = true
|
|
}
|
|
}
|
|
}
|
|
if !flagHolliday {
|
|
fmt.Println("holliday is not a day!")
|
|
}
|
|
}
|
|
/* Output:
|
|
thursday is the 4 th day in the week
|
|
holliday is not a day!
|
|
*/ |