oklog/ulid

How about a MakeFromTime(time.Time) convenience function?

craigpastro opened this issue · 4 comments

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!

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())
}

Yes!

Go for it.

Cool! Thank you.