eyed

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

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

Go to latest
Published: Dec 17, 2021 License: MIT Imports: 5 Imported by: 0

README

go-eyed

A go module for "friendly" IDs.

THIS MODULE IS INCOMPLETE AND NOT CURRENTLY BEING MAINTAINED. THEREFORE, IT SHOULD NOT BE USED

Contribution

If someone would like to contribute to or take over this project, please let me know :)

Notable TODOs

  1. Implement Stringer
  2. Implement database/sql.Scanner and database/sql/driver.Valuer
  3. Play nice with encoding.BinaryMarshal and encoding.BinaryUnmarshal
  4. Support encoding.TextMarshal and encoding.TextUnmarshal (encoding/json friendly)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EYED

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

EYEDs will be 28 characters (including the underscore) plus the length of the prefix.

func Parse

func Parse(id string) (EYED, bool)

Parses the given ID string and returns an EYED object

func (EYED) Ksuid

func (id EYED) Ksuid() ksuid.KSUID

Returns the KSUID for the given EYED

func (EYED) String

func (id EYED) String() string

Returns the string reprsentation of the ID

func (EYED) Type

func (id EYED) Type() *EYEDType

Returns the EYEDType for the given EYED

type EYEDType

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

EYEDType is used to differentiate between different ID types with different prefixes.

func GetType

func GetType(id string) (*EYEDType, bool)

Gets the EYEDType for the given ID string

func RegisterType

func RegisterType(name string, prefix string) *EYEDType

Registers a new distinct type of EYED

func (*EYEDType) Is

func (idType *EYEDType) Is(id string) bool

Checks if the given ID matches the type

func (*EYEDType) Name

func (idType *EYEDType) Name() string

Returns the name of an EYEDType

func (*EYEDType) New

func (idType *EYEDType) New() EYED

Creates a new EYED of the give type

func (*EYEDType) Prefix

func (idType *EYEDType) Prefix() string

Returns the prefix of an EYEDType

func (*EYEDType) Value

func (id *EYEDType) Value() (driver.Value, error)

Jump to

Keyboard shortcuts

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