go-tour/switch-with-no-condition.go

19 lines
276 B
Go
Raw Normal View History

2020-02-05 03:44:36 +00:00
package main
import (
"fmt"
"time"
)
func main() {
t := time.Now()
switch {
case t.Hour() < 12:
fmt.Println("Good morning!")
case t.Hour() < 17:
fmt.Println("Good afternoon.")
default:
fmt.Println("Good evening.")
}
}