Skip to content

Instantly share code, notes, and snippets.

@AaronFlower
Created October 3, 2019 07:28
Show Gist options
  • Save AaronFlower/368e6b7c54a2c2b115d31b013e060dd6 to your computer and use it in GitHub Desktop.
Save AaronFlower/368e6b7c54a2c2b115d31b013e060dd6 to your computer and use it in GitHub Desktop.
go switch with true
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