Advertisement
cwchen

[Go] switch demo

Sep 14th, 2017
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.33 KB | None | 0 0
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "time"
  6. )
  7.  
  8. func main() {
  9.     fmt.Println("When's Saturday?")
  10.     today := time.Now().Weekday()
  11.     switch time.Saturday {
  12.     case today + 0:
  13.         fmt.Println("Today.")
  14.     case today + 1:
  15.         fmt.Println("Tomorrow.")
  16.     case today + 2:
  17.         fmt.Println("In two days.")
  18.     default:
  19.         fmt.Println("Too far away.")
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement