How about a MakeFromTime(time.Time) convenience function?
craigpastro opened this issue · 4 comments
craigpastro commented
In my code I sometimes need to create a ulid from a specific timestamp. To do this I do
ulid.MustNew(ulid.Timestamp(now), ulid.DefaultEntropy())
I wonder if other people do this and if it would be worth having a somewhat simpler
ulid.MakeFromTime(now)
If you think this is worth it, I am happy to create a PR.
Thank you!
peterbourgon commented
So e.g.
// MakeFromTime returns a ULID with the given timestamp and DefaultEntropy. It's
// equivalent to `MustNew(Timestamp(ts), DefaultEntropy())`.
func MakeFromTime(ts time.Time) ulid.ULID {
MustNew(Timestamp(ts), DefaultEntropy())
}
craigpastro commented
Yes!
peterbourgon commented
Go for it.
craigpastro commented
Cool! Thank you.