Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When time goes back the Generate will get repeated ID. #20

Closed
bysir-zl opened this issue Jun 19, 2019 · 1 comment
Closed

When time goes back the Generate will get repeated ID. #20

bysir-zl opened this issue Jun 19, 2019 · 1 comment

Comments

@bysir-zl
Copy link

bysir-zl commented Jun 19, 2019

In line 141: if now == n.time {, I think it has a little problem:

If the time on the machine falls back(now<n.time), duplicate IDS will be generated.

The right way should be like sonyflke (https://github.com/sony/sonyflake/blob/master/sonyflake.go#L96)


This project has the most stars on github. I hope it's perfect. Haha.

@bwmarrin
Copy link
Owner

Maybe take a look at the details in this PR :)

#18

In Go, 1.9 and later, time package uses a monotonic clock for time-measuring operations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants