uid

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

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

Go to latest
Published: Jan 12, 2024 License: MIT Imports: 6 Imported by: 0

README

uid

Golang package for generating prefixed ULID.

Constraints:

  • This package requires prefixes to be exact 5 character long.

Documentation

Overview

Package uid sourced from: https://github.com/ent/contrib/blob/master/entgql/internal/todopulid/ent/schema/pulid/pulid.go

Index

Constants

View Source
const (
	PrefixLen = 5
	ULIDLen   = 26
	IDLen     = PrefixLen + ULIDLen
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ID

type ID string

ID implements a uid - a prefixed ULID.

func MustNew

func MustNew(prefix string) ID

MustNew returns a new uid for time.Now() given a prefix. This uses the default entropy source.

func (*ID) IsValid

func (u *ID) IsValid() bool

IsValid checks the length of an ID. And returns true if the ID length is valid.

func (ID) MarshalGQL

func (u ID) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface.

func (ID) Prefix

func (u ID) Prefix() string

func (*ID) Scan

func (u *ID) Scan(src interface{}) error

Scan implements the Scanner interface.

func (ID) String

func (u ID) String() string

String implements fmt.Stringer interface.

func (*ID) UnmarshalGQL

func (u *ID) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface.

func (*ID) Value

func (u *ID) Value() (driver.Value, error)

Value implements the driver Valuer interface.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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