sandid

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: MIT Imports: 11 Imported by: 3

README

SandID

GitHub Actions codecov Go Report Card PkgGoDev

Every grain of sand on Earth has its own ID.

Note that 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 (see this).

Features

Installation

Open your terminal and execute

$ go get github.com/aofei/sandid

done.

The only requirement is the Go, at least v1.13.

Community

If you want to discuss SandID, or ask questions about it, simply post questions or ideas here.

Contributing

If you want to help build SandID, simply follow this to send pull requests here.

License

This project is licensed under the MIT License.

License can be found here.

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 the SandID that may be null. It implements the database/sql.Scanner so it can be used as a scan destination.

func (*NullSandID) Scan

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

Scan implements the database/sql.Scanner.

func (NullSandID) Value

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

Value implements the driver.Valuer.

type SandID

type SandID [16]byte

SandID is an ID of sand.

func MustParse

func MustParse(s string) SandID

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

func New

func New() SandID

New returns a new instance of the SandID.

func Parse

func Parse(s string) (SandID, error)

Parse parses the s into a new instance of the 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 the encoding.BinaryMarshaler.

func (SandID) MarshalJSON

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

MarshalJSON implements the json.Marshaler.

func (SandID) MarshalText

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

MarshalText implements the encoding.TextMarshaler.

func (*SandID) Scan

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

Scan implements the 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 the encoding.BinaryUnmarshaler.

func (*SandID) UnmarshalJSON

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

UnmarshalJSON implements the json.Unmarshaler.

func (*SandID) UnmarshalText

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

UnmarshalText implements the encoding.TextUnmarshaler.

func (SandID) Value

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

Value implements the driver.Valuer.

Jump to

Keyboard shortcuts

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