mirror of
https://github.com/TeaOSLab/EdgeNode.git
synced 2025-11-10 20:50:25 +08:00
实现HTTP部分功能
This commit is contained in:
15
internal/utils/ticker_utils.go
Normal file
15
internal/utils/ticker_utils.go
Normal file
@@ -0,0 +1,15 @@
|
||||
package utils
|
||||
|
||||
import "time"
|
||||
|
||||
// 定时运行某个函数
|
||||
func Every(duration time.Duration, f func(ticker *Ticker)) *Ticker {
|
||||
ticker := NewTicker(duration)
|
||||
go func() {
|
||||
for ticker.Next() {
|
||||
f(ticker)
|
||||
}
|
||||
}()
|
||||
|
||||
return ticker
|
||||
}
|
||||
Reference in New Issue
Block a user