SHARE
TWEET

Untitled

a guest Mar 21st, 2019 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package main
  2.  
  3. import (
  4.     "fmt"
  5.     "time"
  6. )
  7.  
  8. func main() {
  9.  
  10.     go Remind("Time to eat", 10*time.Second)
  11.     go Remind("Time to work", 30*time.Second)
  12.     Remind("Time to sleep", 60*time.Second)
  13.  
  14. }
  15.  
  16. func Remind(text string, delay time.Duration) {
  17.     for {
  18.         time.Sleep(delay)
  19.         currentTime := time.Now()
  20.         fmt.Printf("The time is %s: %s \n", currentTime.Format("15:04:05"), text)
  21.     }
  22. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top