1.判断2个时间是否超时
package main import ( "fmt" "time" ) func main() { //获取1秒后时间 var NowTime = time.Now().Add(time.Second * 1) //循环 for { //判断时间是否超时 if time.Now().After(NowTime) { fmt.Println(NowTime) NowTime = time.Now().Add(time.Second * 1) } //暂停1秒 time.Sleep(1000000000) } }