Documentation ¶
Overview ¶
Package id aliases ULID from github.com/oklog/ulid as ID and provides some additional functions useful for IDs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Zero is a ID with all numbers zeroed. Zero = ulid.MustParseStrict("00000000000000000000000000") )
Functions ¶
Types ¶
type ID ¶
ID aliases ULID. While ULID could be used directly, using the alias avoids repeating the external dependency in all other packages.
func FromParts ¶
FromUint64 creates a ULID from an uint64.
The time parameter is used for the time part. It is converted to Unix timestamp of millisecond precision. The rand parameter is used for the random part. It is prepended with 2 zeroed bytes, since the random part is 10 byte long, but the integer is only 8 byte long.
func FromString ¶
FromString returns a ULID with the time part zeroed and the random part set to the 64 bit xxhash value of str.
func MustParse ¶
MustParse parses an encoded ULID, panicking in case of failure. See ulid package on MustParseStrict for details. This function should only be used on safe strings.