guid

package
v0.0.0-...-e540e72 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 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(id string) GUID

MustParse 解析全局唯一ID

func New

func New() GUID

New 生成全局唯一ID 4 byte: 时间戳(S) 2 byte: 主机号 2 byte: 进程号 2 byte: 流水号 2 byte: 随机数

func NewWithTime

func NewWithTime(t time.Time) GUID

NewWithTime 生成全局唯一ID

func Parse

func Parse(id string) (GUID, error)

Parse 解析全局唯一ID

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) HostID

func (g GUID) HostID() uint16

HostID returns the host 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) 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) ProcessID

func (g GUID) ProcessID() uint16

ProcessID returns the process ID.

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.

Jump to

Keyboard shortcuts

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