by Jabbles · 11y ago · 0 comments
Now().UnixNano() is not guaranteed to be monotonically increasing. I'd be more careful if your keys really do need to be unique.
You can use time.Truncate to get the 10 minute interval.
var t time.Time
t = start
for {
if t.After(stop) {
break
}
/* ... */
t = t.Add(d)
}
Would usually be written: for t := start; !t.After(stop); t = t.Add(d) {