ulids

package
v0.7.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 20, 2026 License: Apache-2.0 Imports: 5 Imported by: 4 modules, 8 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package ulids is a lightweight wrapper around the github.com/oklog/ulid package that provides some common functionality (like checking if a ULID is null or is zero) as well as a process-global, cryptographically random, monotonic, and thread-safe ulid generation mechanism that can be used from external packages

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrUnknownType = errors.New("cannot parse input: unknown type")
)
View Source
var Null = ulid.ULID{0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}

Null ULID pre-allocated for easier checking.

Functions

func Bytes

func Bytes(uid any) ([]byte, error)

Bytes parses a ULID and returns the []byte representation of the ULID

func FromTime

func FromTime(ts time.Time) ulid.ULID

FromTime creates a ULID with the specified timestamp

func IsZero

func IsZero(uid ulid.ULID) bool

IsZero determines if the specified uid is the Null or zero-valued ULID. Useful for determining if a ULID has been passed into a method or is valid

func MustBytes

func MustBytes(uid any) []byte

MustBytes parses the ULID into bytes but panics on errors

func MustParse

func MustParse(uid any) (id ulid.ULID)

MustParse parses the ULID but panics on errors

func New

func New() ulid.ULID

New creates a new montonically increasing ULID in a threadsafe manner using a cryptographically random source of entropy for security (e.g. to ensure that an attacker cannot guess the next ULID to be generated). If the ULID cannot be generated this method panics rather than returning an error

func Parse

func Parse(uid any) (ulid.ULID, error)

Parse a ULID from a string or a []byte (or return a ulid.ULID). This method makes it easier to convert any user-specified type into a ULID

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL