I didn't get the "type-safe" part. How would it work in Go? Let's say I have structs: type User struct { ID TypeID } type Post struct { ID TypeID } How can I ensure the correct type is used in each of the structs?
Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
61–70 of 236 posts
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#62Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#63Assuming you don't need to use UUIDv7 (or any UUID's) then https://github.com/segmentio/ksuid provides a much bigger keyspace. You could just append a string prefix if you wanted to namespace, but the chance of collisions of a ksuid is many times smaller than a UUID of any version. ksuid is the best general purpose id generator with sort-able timestamps I've found and has libraries in most languages. UUID v1-7 are wa…
1: https://github.com/svix/rust-ksuid 2: https://github.com/svix/python-ksuid
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#64Unrelated, but this links to "Crockford's alphabet", https://www.crockford.com/base32.html , which is a base-32 system that includes all alphanumeric characters except I and L (which are confusable with 1), O (which is confusable with 0), and U (????). The page says the reason for excluding U is "accidental obscenity'. What the heck is it talking about?
Crockford is being cheeky. To make a nice base32 alphabet out of non-confusable alphanumeric characters you only need to exclude O, I, and L. This leaves you with 33 characters still, so you need to remove one more, and it doesn't matter which one you remove, so you might as well pick an arbitrary reason for the last character that gets removed (and it's not the worst reason, if your goal is to use these as user-readable IDs, although obviously it's not even remotely bulletproof).
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#65Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#66I didn't get the "type-safe" part. How would it work in Go? Let's say I have structs: type User struct { ID TypeID } type Post struct { ID TypeID } How can I ensure the correct type is used in each of the structs?
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#67I didn't get the "type-safe" part. How would it work in Go? Let's say I have structs: type User struct { ID TypeID } type Post struct { ID TypeID } How can I ensure the correct type is used in each of the structs?
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#68Good, but I dont see a big advantage over UUIDv7 Anyone has some good ones?
If you don't need either of those, then UUIDv7 is the right choice.
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#69I didn't get the "type-safe" part. How would it work in Go? Let's say I have structs: type User struct { ID TypeID } type Post struct { ID TypeID } How can I ensure the correct type is used in each of the structs?
Re: Type-safe, K-sortable, globally unique identifier inspired by Stripe IDs
#70Unrelated, but this links to "Crockford's alphabet", https://www.crockford.com/base32.html , which is a base-32 system that includes all alphanumeric characters except I and L (which are confusable with 1), O (which is confusable with 0), and U (????). The page says the reason for excluding U is "accidental obscenity'. What the heck is it talking about?
If I and O are already excluded and you also exclude U that removes a lot of potential rude looking three letter combinations like *** and *** and *** and also the four letter ones like **** and **** and the dreaded ****. Of course because you have A then **** is still a possibility but very very unlikely
Guess that's a credit to the general civility of the community.
EDIT: It appears that other people in this thread are freely using profanity, so either your comment was targeted by automation due to the unusual density of banned words, or it's a joke that went over my head :)