Created
October 3, 2019 07:28
-
-
Save AaronFlower/368e6b7c54a2c2b115d31b013e060dd6 to your computer and use it in GitHub Desktop.
go switch with true
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment