Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Go 0.42 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement