Documentation ¶
Index ¶
- Constants
- Variables
- func Encoding() *base32.Encoding
- func MaxTime() time.Time
- func SetSource(src io.Reader) (err error)
- type MonotonicReader
- type TS
- type ULID
- func (u ULID) AppendFormat(dst []byte) []byte
- func (u ULID) Bytes() []byte
- func (u ULID) Compare(o ULID) int
- func (u ULID) MarshalBinary() ([]byte, error)
- func (u ULID) MarshalText() ([]byte, error)
- func (u *ULID) Scan(src interface{}) error
- func (u ULID) String() string
- func (u ULID) Timestamp() TS
- func (u *ULID) UnmarshalBinary(b []byte) error
- func (u *ULID) UnmarshalText(b []byte) error
- func (u ULID) Value() (driver.Value, error)
Constants ¶
const ( // CrockfordBase32 is the ULID encoding alphabet, missing I,L,O,U // to avoid confusion and abuse. See: http://www.crockford.com/wrmg/base32.html CrockfordBase32 = "0123456789ABCDEFGHJKMNPQRSTVWXYZ" // EncodedLen is the length of a text encoded ULID. EncodedLen = 26 // BinaryLen is the length of a binary ULID. BinaryLen = len(ULID{}) )
Variables ¶
var ( // ErrTimeOverflow is returned if a timestamp overflowing max time is provided to MonotonicReader. ErrTimeOverflow = errors.New("ulid: timestamp overflows max time") // ErrNegativeTime is returned if a timestamp predating the previous is provided to MonotonicReader. ErrNegativeTime = errors.New("ulid: timestamp predates previous") // ErrMonotonicOverflow is returned when incrementing previous ULID's entropy bytes would result // in an entropy overflow. The solution is to call .Next() again with a later timestamp. ErrMonotonicOverflow = errors.New("ulid: monotonic entropy overflow") )
var ( // ErrInvalidLength is returned when a parse/unmarshal is attempted on data of incorrect length. ErrInvalidLength = errors.New("ulid: invalid data length") // ErrOverflowsULID is returned when a base32 value of valid CrockfordBase32 and encoded length // is passed to parse/unmarshal, but represents a decoded value that would overflow ULID{}. This // can occur as a ULID is 128 bit, while a EncodedLen of CrockfordBase32 can contain 130 bits. ErrOverflowsULID = errors.New("ulid: base32 overflows ULID") // ErrBadScanSource is returned when an SQL scan is attempted with a non string/[]byte source. ErrBadScanSource = errors.New("ulid: scan src must be string or []byte") )
Functions ¶
func Encoding ¶
Encoding returns the ULID base32 encoding prepared using CrockfordBase32 and no padding.
Types ¶
type MonotonicReader ¶
type MonotonicReader struct {
// contains filtered or unexported fields
}
MonotonicReader ...
func NewMonotonicReader ¶
func NewMonotonicReader(src io.Reader) (*MonotonicReader, error)
NewMonotonicReader returns a new instance for given entropy source and read buffer size. Note that 'src' MUST yield random bytes or else monotonic reads are not guaranteed to terminate, since there may not be enough entropy to compute a monotonic increment.
type TS ¶
type TS uint64
TS represents a Unix time in milliseconds.
type ULID ¶
type ULID [16]byte
ULID ...
func ParseString ¶
ParseString will parse a text-encoded ULID from string.
func (ULID) AppendFormat ¶
AppendFormat append text encoded ULID to 'dst'.
func (ULID) Compare ¶
Compare returns integer value from comparison between receiving and argument ULID lexographically.
0 -> (u == o), -1 -> (u < o), 1 -> (u > 0).
func (ULID) MarshalBinary ¶
MarshalBinary implements encoding.BinaryMarshaler.
func (ULID) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*ULID) UnmarshalBinary ¶
UnmarshalBinary implements encoding.BinaryUnmarshaler.
func (*ULID) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.