Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var NilUUID = UUID{}
NilUUID is a UUID with all bits set to 0. As a string, it is represented as "00000000-0000-0000-0000-000000000000".
var ( UUIDURLNamespace = UUIDNamespace{ Name: "URL", UUID: UUID{0x6b, 0xa7, 0xb8, 0x11, 0x9d, 0xad, 0x11, 0xd1, 0x80, 0xb4, 0x00, 0xc0, 0x4f, 0xd4, 0x30, 0xc8}, } )
Functions ¶
func NanoID ¶
func NanoID() *nanoID
NanoID is implements Nano ID found at https://github.com/ai/nanoid.
To configure the size, use chaining:
id := NanoID().SetSize(12).Get().
To set a different alphabet method chaining:
fmt.Println(NanoID().SetAlphabet("base56").SetSize(13)).
When anything goes wrong generating the Nano ID, the empty string is returned.
func UUIDIsValid ¶
UUIDIsValid returns whether the string represents a UUID v1, or v4. Note that value is not trimmed of spaces.
Types ¶
type UUID ¶
type UUID [16]byte
UUID defines a type big enough to hold a a RFC 4122 Universally Unique IDentifier.
func UUIDFromString ¶
UUIDFromString creates a UUID instance from a UUID represented by the string s. If s is not a UUID, the nil UUID (all bits 0) is returned. The string can be with or without hyphens.
func UUIDv4 ¶
func UUIDv4() UUID
UUIDv4 returns a UUID version 4 (random). See https://tools.ietf.org/html/rfc4122.
func UUIDv5 ¶
func UUIDv5(namespace UUIDNamespace, name string) UUID
UUIDv5 returns a UUID using namespace and name. See https://tools.ietf.org/html/rfc4122.
func (UUID) MarshalJSON ¶
MarshalJSON returns the JSON encoding of u.
func (UUID) String ¶
CodeAsHex returns the 36 character long string string representation of the UUID. It looks like `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`.
func (*UUID) UnmarshalJSON ¶
UnmarshalJSON parses the JSON-encoded data and stores the result in u.
type UUIDNamespace ¶
UUIDNamespace defines a UUID v5 namespace.