代码如下:为什么输入的时间戳事变化的,得到的result在某个区间内是一样的?//main.gofuncPrevSlot(nowint64)int64{//now=time.Now().Unix()varblockInterval=int64(10)result:=int64((now-1)/blockInterval)*blockInterval//whyresultissame?plog.Println("PrevSlot:",int64(result),int64((now-1)/blockInterval),now)returnresult}funcmain(){ticker:=time.NewTicker(1*time.Second)for{<-ticker.Cnow:=time.Now().Unix()PrevSlot(now)}}/**output:2019-01-1610:58:31.668597I|dpos.go:PrevSlot:154760751015476075115476075112019-01-1610:58:32.668649I|dpos.go:PrevSlot:154760751015476075115476075122019-01-1610:58:33.668568I|dpos.go:PrevSlot:154760751015476075115476075132019-01-1610:58:34.668572I|dpos.go:PrevSlot:154760751015476075115476075142019-01-1610:58:35.668547I|dpos.go:PrevSlot:15476075101547607511547607515*/
哔哔one
小怪兽爱吃肉
相关分类