You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
funcmain() {
// Create a new Node with a Node number of 1node, err:=snowflake.NewNode(1)
iferr!=nil {
fmt.Println(err)
return
}
// Generate a snowflake ID.id:=node.Generate()
// Print out the ID in a few different ways.fmt.Println(id)
fmt.Println(id.Base64())
b:=id.IntBytes()
fmt.Println(base64.StdEncoding.EncodeToString(b[:]))
}
I think, there is no problem here. As I understand @jiaoyuedave ran the code in golang playground. In the golang playground, the time is before the snowflake default epoch. The generated id can never be negative number. This cannot be happened in real life. Also generated base64 result is correct according to the Id.
result:
dig into souce, i found that base64 method use string representation of int64 for encoding, which make no sense:
it only make representation much longer.
The text was updated successfully, but these errors were encountered: