mirror of
https://github.com/hybridgroup/gobot.git
synced 2025-04-26 13:48:49 +08:00
21 lines
235 B
Go
21 lines
235 B
Go
package gobot
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
func Every(t time.Duration, f func()) {
|
|
go func(){
|
|
for{
|
|
time.Sleep(t)
|
|
f()
|
|
}
|
|
}()
|
|
}
|
|
|
|
func After(t time.Duration, f func()) {
|
|
go func(){
|
|
time.Sleep(t)
|
|
f()
|
|
}()
|
|
} |