akshayvadher / cuid2

Next generation guids. Secure, collision-resistant ids optimized for horizontal scaling and performance. CUID2 in Go
MIT License
4 stars 1 forks source link

Remove the length validation #12

Closed akshayvadher closed 3 months ago

akshayvadher commented 3 months ago

Revert #10

Because I tested the original library and the following works,

const id = init({ length: 150 });
console.log(id());
// p0m6ycspza37iwloxpn5zw0nqtbkbcycha5mm6jlqzsu33qrlh84kmkvi41qt2w5khcddvb7a50wsczoy1o795rs75b3ifld3u

So

  1. this does not match with the original spec.
  2. since we are returning error, user cannot use this inline, they will have to define it first and then pass
    
    myFunction(CreateId()) // this won't work

id, err := CreateId() myFunction(id) // only this will work. This is cumbersome and for most cases, not required.

akshayvadher commented 3 months ago

Added panic instead of error because the gain from validation was too small as compared to usability issue