Source file tour/flowcontrol/switch-evaluation-order.go
1 //go:build OMIT 2 3 package main 4 5 import ( 6 "fmt" 7 "time" 8 ) 9 10 func main() { 11 fmt.Println("When's Saturday?") 12 today := time.Now().Weekday() 13 switch time.Saturday { 14 case today + 0: 15 fmt.Println("Today.") 16 case today + 1: 17 fmt.Println("Tomorrow.") 18 case today + 2: 19 fmt.Println("In two days.") 20 default: 21 fmt.Println("Too far away.") 22 } 23 } 24