segmentio / ksuid

K-Sortable Globally Unique IDs
https://segment.com/blog/a-brief-history-of-the-uuid/
MIT License
4.82k stars 174 forks source link

How do I convert from `string` to `ksuid.KSUID` format? #52

Open myrtleTree33 opened 2 years ago

myrtleTree33 commented 2 years ago

Hi,

I would like to check if this approach is correct:

id := &ksuid.KSUID{}
id.UnmarshalText([]byte(IdStr))
pavel-github commented 2 years ago

@myrtleTree33, I would recommend to use ksuid.Parse(YourIdStr) method: https://github.com/segmentio/ksuid/blob/master/ksuid.go#L177-L191 It's used in ksuid inspect command as well.