Time 时间lib
示例
package main
import (
"fmt"
"time"
)
func main() {
seconds := 10
fmt.Print(time.Duration(seconds) * time.Second) // prints 10s
fmt.Println()
hours, _ := time.ParseDuration("10h")
fmt.Printf("%v %#v %T\n", hours, hours, hours)
// 每个3秒执行
ticker := time.NewTicker(time.Second * 3)
for {
fmt.Println("hit")
<-ticker.C
}
}