go switch statements code example
Example 1: go switch statement
switch time {
case "morning":
fmt.Println("Time to wake up!")
case "night":
fmt.Println("Time to go to bed.")
default:
fmt.Println("Enjoy life")
}
Example 2: go switch case
switch time.Now().Weekday() {
case time.Saturday, time.Sunday:
fmt.Println("It's the weekend")
default:
fmt.Println("It's a weekday")
}