-
Notifications
You must be signed in to change notification settings - Fork 2
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
generate unique id using timestamp + random bits #214
Conversation
SeeratSek
commented
May 25, 2018
- used rs/xid package (https://blog.kowalczyk.info/article/JyRZ/generating-good-unique-ids-in-go.html)
- change Players to use id as key
- players with same name can now play concurrently
- used rs/xid package - change Players to use id as key - players with same name can now play concurrently
@@ -61,6 +64,11 @@ func CreatePlayer(n string, p Position, c string, ws *websocket.Conn) *Player { | |||
} | |||
} | |||
|
|||
func GenUniqueID() string { | |||
id := xid.New() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool new lib
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very cool indeed. Was this package added using dep? The Gopkg.toml file should have been updated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
soo I imported the package before calling dep -add and now i'm having trouble doing dep -add after the fact.. (golang/dep#1670). I can just manually update the Gopkg.toml file with the constraint right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure! Try that and when you update, I'll pull this branch and try running dep ensure to see if it works
Pull Request Test Coverage Report for Build 138
💛 - Coveralls |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect