typeid

package
v0.0.0-...-2dfab7d Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const SlugLength = 7

Variables

This section is empty.

Functions

This section is empty.

Types

type TypeID

type TypeID struct {
	// contains filtered or unexported fields
}

func FromString

func FromString(idStr string) *TypeID

Returns a typeID given a string. String should be in the format of ([a-zA-Z0-9]+)_([a-zA-Z0-9]+)

func New

func New(typePrefix string) *TypeID

Generates a random TypeID with the given type prefix.

func (*TypeID) Bytes

func (id *TypeID) Bytes() []byte

Returns the id portion of the TypeID (without the type prefix). The random bytes are a valid UUID v4.

func (*TypeID) Slug

func (id *TypeID) Slug() string

Returns a 7-character slug that is URL friendly.

Slugs meet the following properties: - They are 7 characters long - The slug is a prefix of the random character portion of a TypeID. - Slugs use the base58 character set, in order to avoid confusion between similar characters. - Some effort is put to avoid the most common curse words.

func (*TypeID) String

func (id *TypeID) String() string

The TypeID in string format.

TypeIDs have the following format:

prefix_1234567abcdefghijklmnopq

Where:

  • prefix is prefix suffix specified at creation time
  • '_' is used as a separator between the type prefix and the random character of the id.
  • 1234567 are seven characters that can be used as a slug, from the base58 character set.
  • abcdefghijklmnopq are 17 random characters from the base62 character set.

func (*TypeID) Type

func (id *TypeID) Type() string

Returns the type prefix

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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