uuid icon indicating copy to clipboard operation
uuid copied to clipboard

Allow to use something different than `time.Now` when generating uuids that have a time component

Open satazor opened this issue 1 year ago • 4 comments

Allow to use something different than time.Now when generating uuids that have a time component.

This is useful for:

  • Tests
  • In rare cases where you want to encode a timestamp different than the current time in the id, such as an expiration date.

The package at https://github.com/gofrs/uuid seems to have this functionality, see https://pkg.go.dev/github.com/gofrs/uuid/v5#WithEpochFunc. I would love to have something similar.

satazor avatar Jul 29 '24 10:07 satazor

If you have special requirements, please use uuidv8

it512 avatar Jul 30 '24 02:07 it512

Yes, please add a way to generate uuidv7 with a custom time, right now we can sort by uuidv7, but if we want to get records from database between dates, it's way too complicated right now, if we can generate a uuidv7 with a custom dates this makes it much simpler.

liron-navon avatar Dec 22 '24 15:12 liron-navon

I will add the v8 implementation , later

it512 avatar Dec 23 '24 07:12 it512

hey, @it512 - v8 proposal is already up there - #178 . we're awaiting reviews from the maintainers.

ashwingopalsamy avatar Apr 11 '25 06:04 ashwingopalsamy