sandid

package module
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2025 License: MIT Imports: 10 Imported by: 3

README

SandID

Test codecov Go Report Card Go Reference

Every grain of sand on Earth has its own ID.

The algorithm used to generate the sandid.SandID mainly come from the UUID version 1. Some adjustments were made to enhance the efficiency of database insertion.

Features

Installation

To use this project programmatically, go get it:

go get github.com/aofei/sandid

Community

If you have any questions or ideas about this project, feel free to discuss them here.

Contributing

If you would like to contribute to this project, please submit issues here or pull requests here.

When submitting a pull request, please make sure its commit messages adhere to Conventional Commits 1.0.0.

License

This project is licensed under the MIT License.

Documentation

Overview

Package sandid implements a unique ID generation algorithm to ensure that every grain of sand on Earth has its own ID.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Compare

func Compare(a, b SandID) int

Compare returns an integer comparing the a and b lexicographically. The result will be 0 if a == b, -1 if a < b, and +1 if a > b.

func Equal

func Equal(a, b SandID) bool

Equal reports whether the a and b are equal.

Types

type NullSandID

type NullSandID struct {
	SandID SandID
	Valid  bool
}

NullSandID represents an instance of SandID that may be null. It implements database/sql.Scanner so it can be used as a scan destination.

func (*NullSandID) Scan

func (nsID *NullSandID) Scan(value interface{}) error

Scan implements database/sql.Scanner.

func (NullSandID) Value

func (nsID NullSandID) Value() (driver.Value, error)

Value implements driver.Valuer.

type SandID

type SandID [16]byte

SandID is an ID of sand.

func MustParse

func MustParse(s string) SandID

MustParse is like Parse, but panics if the s cannot be parsed.

func New

func New() SandID

New creates a new instance of SandID.

func Parse

func Parse(s string) (SandID, error)

Parse parses the s into a new instance of SandID.

func (SandID) IsZero

func (sID SandID) IsZero() bool

IsZero reports whether the sID is zero.

func (SandID) MarshalBinary

func (sID SandID) MarshalBinary() ([]byte, error)

MarshalBinary implements encoding.BinaryMarshaler.

func (SandID) MarshalJSON

func (sID SandID) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler.

func (SandID) MarshalText

func (sID SandID) MarshalText() ([]byte, error)

MarshalText implements encoding.TextMarshaler.

func (*SandID) Scan

func (sID *SandID) Scan(value interface{}) error

Scan implements database/sql.Scanner.

The value must be a string or []byte.

func (SandID) String

func (sID SandID) String() string

String returns the serialization of the sID.

func (*SandID) UnmarshalBinary

func (sID *SandID) UnmarshalBinary(data []byte) error

UnmarshalBinary implements encoding.BinaryUnmarshaler.

func (*SandID) UnmarshalJSON

func (sID *SandID) UnmarshalJSON(data []byte) error

UnmarshalJSON implements json.Unmarshaler.

func (*SandID) UnmarshalText

func (sID *SandID) UnmarshalText(text []byte) error

UnmarshalText implements encoding.TextUnmarshaler.

func (SandID) Value

func (sID SandID) Value() (driver.Value, error)

Value implements driver.Valuer.

Jump to

Keyboard shortcuts

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