ticker.go
package main
import (
"time"
"fmt"
)
func main() {
StartTimer()
}
func StartTimer() {
t := time.NewTicker(time.Second * 1)
for {
<-t.C;
//Do something
fmt.Println(time.Now())
}
}
本文共 266 字,大约阅读时间需要 1 分钟。
ticker.go
package main
import (
"time"
"fmt"
)
func main() {
StartTimer()
}
func StartTimer() {
t := time.NewTicker(time.Second * 1)
for {
<-t.C;
//Do something
fmt.Println(time.Now())
}
}
转载于:https://www.cnblogs.com/xiaohao073/p/6879021.html