github.com/gogf/gf@v1.16.9/os/gtimer/gtimer_z_example_test.go (about) 1 // Copyright GoFrame Author(https://goframe.org). All Rights Reserved. 2 // 3 // This Source Code Form is subject to the terms of the MIT License. 4 // If a copy of the MIT was not distributed with this file, 5 // You can obtain one at https://github.com/gogf/gf. 6 7 package gtimer_test 8 9 import ( 10 "fmt" 11 "time" 12 13 "github.com/gogf/gf/os/gtimer" 14 ) 15 16 func Example_add() { 17 now := time.Now() 18 interval := 1400 * time.Millisecond 19 gtimer.Add(interval, func() { 20 fmt.Println(time.Now(), time.Duration(time.Now().UnixNano()-now.UnixNano())) 21 now = time.Now() 22 }) 23 24 select {} 25 }