Documentation ¶
Overview ¶
Package id provides types and functions for generation of identifiers.
Index ¶
Constants ¶
const Size = 20
Size is the size of an ID.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type ID ¶
ID is a codeable unique identifier.
func Unique ¶
func Unique() ID
Unique returns a unique identifier by hashing the current time and machine hostname.
func (ID) MarshalJSON ¶
MarshalJSON encodes the ID as a JSON string.
func (*ID) Parse ¶
Parse parses lowercase string s as a 20 byte hex-encoded ID, or copies s to the ID if it is 20 bytes long.
func (*ID) UnmarshalJSON ¶
UnmarshalJSON decodes a JSON string as an ID.
type Remapper ¶
type Remapper interface { RemapIndex(ctx context.Context, index int64) (ID, error) RemapID(ctx context.Context, id ID) (int64, error) }
Remapper is an interface which allows remapping between ID to int64. One such remapper can be stored in the current Context. This is used to handle resource when converting to/from proto. It needs to live here to break go package dependency cycles.
func GetRemapper ¶
GetRemapper returns the Remapper attached to the given context.