github.com/TeaOSLab/EdgeNode@v1.3.8/internal/utils/ticker_utils.go (about) 1 package utils 2 3 import ( 4 "github.com/TeaOSLab/EdgeNode/internal/goman" 5 "time" 6 ) 7 8 // Every 定时运行某个函数 9 func Every(duration time.Duration, f func(ticker *Ticker)) *Ticker { 10 ticker := NewTicker(duration) 11 goman.New(func() { 12 for ticker.Next() { 13 f(ticker) 14 } 15 }) 16 17 return ticker 18 }