guid

package
v0.0.0-...-3077202 Latest Latest
Warning

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

Go to latest
Published: May 23, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	BLen = 12 // GUID字节长度
	SLen = 20 // GUID字符长度
	Base = 36 // GUID转换进制
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GUID

type GUID [BLen]byte

GUID is the global unique ID.

var (
	NULL GUID // 空GUID

)

func MustParse

func MustParse(s string) GUID

MustParse parses a GUID from a string.

func New

func New() GUID

New returns a new GUID.

func NewWithTime

func NewWithTime(tm time.Time) GUID

NewWithTime returns a new GUID with the given time.

func Parse

func Parse(s string) (GUID, error)

Parse parses a GUID from a string.

func (GUID) Bytes

func (g GUID) Bytes() []byte

Bytes returns the byte slice.

func (GUID) Empty

func (g GUID) Empty() bool

Empty returns true if the ID is empty.

func (GUID) Equal

func (g GUID) Equal(id GUID) bool

Equal returns true if the two IDs are equal.

func (GUID) Gt

func (g GUID) Gt(id GUID) bool

Gt returns true if the first ID is greater than the second ID.

func (GUID) Gte

func (g GUID) Gte(id GUID) bool

Gte returns true if the first ID is greater than or equal to the second ID.

func (GUID) Lt

func (g GUID) Lt(id GUID) bool

Lt returns true if the first ID is less than the second ID.

func (GUID) Lte

func (g GUID) Lte(id GUID) bool

Lte returns true if the first ID is less than or equal to the second ID.

func (GUID) MarkID

func (g GUID) MarkID() uint32

MarkID returns the mark ID.

func (GUID) MarshalBinary

func (g GUID) MarshalBinary() (data []byte, err error)

MarshalBinary implements the encoding.BinaryMarshaler interface.

func (GUID) MarshalJSON

func (g GUID) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

func (GUID) MarshalText

func (g GUID) MarshalText() (text []byte, err error)

MarshalText implements the encoding.TextMarshaler interface.

func (GUID) Random

func (g GUID) Random() uint16

Random returns the random number.

func (GUID) Reset

func (g GUID) Reset()

func (*GUID) Scan

func (g *GUID) Scan(src any) error

Scan implements the sql.Scanner interface.

func (GUID) Serial

func (g GUID) Serial() uint16

Serial returns the serial number.

func (GUID) String

func (g GUID) String() string

String returns the string.

func (GUID) Unix

func (g GUID) Unix() int64

Unix returns the timestamp.

func (*GUID) UnmarshalBinary

func (g *GUID) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*GUID) UnmarshalJSON

func (g *GUID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements the json.Unmarshaler interface.

func (*GUID) UnmarshalText

func (g *GUID) UnmarshalText(text []byte) error

UnmarshalText implements the encoding.TextUnmarshaler interface.

func (GUID) Value

func (g GUID) Value() (driver.Value, error)

Value implements the driver.Valuer interface.

type Generator

type Generator interface {
	New() GUID
	NewWithTime(tm time.Time) GUID
}

func NewGenerator

func NewGenerator(mark uint32) Generator

NewGenerator returns a new Generator.

Jump to

Keyboard shortcuts

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