Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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 ¶
func NewFromBytes ¶
func NewV7 ¶
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) HasValidTableName ¶
func (*OID) SetTableName ¶
SetTableName sets the 3-letter DB table name. This is non-standard for UUIDs.
func (*OID) 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 .