oid

package module
v0.0.0-...-c1d9bce Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 7 Imported by: ? modules, 0 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.

README

oid

A self-contained DB ref in the form of a UUID version 7 primary index into a DB table name embedded.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Nil = uuid.Nil()

Nil is used as a flag value, for example for an empty foreign key UUID (i.e. a link to another object).

Functions

This section is empty.

Types

type OID

type OID uuid.UUID

func NewFromBytes

func NewFromBytes(b []byte) (OID, error)

func NewV7

func NewV7(tableName string) OID

OID is a UUID that borrows from the Go stdlib UUID version 7 a bit, and veers from the RFC a bit. It is not field-for-field compatible with RFC 9562 standard UUID v7, but it is fully interoperable.

  • Input argument "tableName", the DB table name, must be either three letters or the empty string (""). NOTE: To favor UC or LC (or neither) is TBD.
  • Version 7 UUIDs have a timestamp in the first 48 bits, and at least 62 bits of random data
  • func NewV7 returns UUIDs that sort in increasing order, except if the system clock moves backwards
  • Go stdlib UUID v7 overwrites field "rand_a" with a nanoseconds field, as permitted by the v7 spec
  • Contrary to spec, OID overwrites the last 24 bits of field "rand_b" with a three-letter DB table code, so that each OID is a self-contained DB reference - except that the three-letter code must (tipicly) be translated to a full DB table name.
  • These two changes reduce the random in the UUID from a possible max of 74 bits down to an effective 38 bits.

Note that OIDs are comparable using the "==" operator, because a UUID is an array (not a slice). "==" WORKS! .

func (*OID) Bytes

func (u *OID) Bytes() []byte

func (*OID) HasValidTableName

func (u *OID) HasValidTableName() bool

func (*OID) IsNil

func (u *OID) IsNil() bool

func (*OID) IsSet

func (u *OID) IsSet() bool

func (*OID) SetTableName

func (u *OID) SetTableName(s string)

SetTableName sets the 3-letter DB table name. This is non-standard for UUIDs.

func (*OID) String

func (u *OID) String() string

String assumes a UUID v7 with modifications. It renders the OID as "YMDHM-XXX-CCC":

  • YMDHM is the m5 app's compressed date & time (e.g. 6bpi0 = 2026, 11=Nov, i = 18th, 0=00:00)
  • XXX is the stdlib's sub-ms ns field (0..4095)
  • CCC is the (non-standard!) DB table name

For the lowercase hex-and-dash representation defined in RFC 9562, use uuid.UUID.String .

func (*OID) TableName

func (u *OID) TableName() string

TableName returns the 3-letter DB table name. This is non-standard for UUIDs.

func (*OID) UUID

func (u *OID) UUID() uuid.UUID

Jump to

Keyboard shortcuts

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