Advertisement
cwchen

[Go] switch with fallthrough demo.

Sep 14th, 2017
428
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.41 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "time"
  6. )
  7.  
  8. func main() {
  9.     now := time.Now().Weekday()
  10.  
  11.     switch now {
  12.     case time.Monday:
  13.         fallthrough
  14.     case time.Tuesday:
  15.         fallthrough
  16.     case time.Thursday:
  17.         fmt.Println("Week")
  18.     case time.Wednesday:
  19.         fmt.Println("Hump day")
  20.     case time.Friday:
  21.         fmt.Println("Thank God It's Friday")
  22.     case time.Saturday:
  23.         fallthrough
  24.     case time.Sunday:
  25.         fmt.Println("Weekend")
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement