const ( // ErrInvalidID is returned when trying to unmarshal an invalid ID. ErrInvalidID strErr = "xid: invalid ID" )
func Sort(ids []ID)
Sort sorts an array of IDs inplace. It works by wrapping `[]ID` and use `sort.Sort`.
ID represents a unique request id
type ID [rawLen]byte
func FromBytes(b []byte) (ID, error)
FromBytes convert the byte array representation of `ID` back to `ID`
func FromString(id string) (ID, error)
FromString reads an ID from its string representation
func New() ID
New generates a globally unique ID
func NewWithTime(t time.Time) ID
NewWithTime generates a globally unique ID with the passed in time
func NilID() ID
NilID returns a zero value for `xid.ID`.
func (id ID) Bytes() []byte
Bytes returns the byte array representation of `ID`
func (id ID) Compare(other ID) int
Compare returns an integer comparing two IDs. It behaves just like `bytes.Compare`. The result will be 0 if two IDs are identical, -1 if current id is less than the other one, and 1 if current id is greater than the other.
func (id ID) Counter() int32
Counter returns the incrementing value part of the id. It's a runtime error to call this method with an invalid id.
func (id ID) Encode(dst []byte) []byte
Encode encodes the id using base32 encoding, writing 20 bytes to dst and return it.
func (id ID) IsNil() bool
IsNil Returns true if this is a "nil" ID
func (id ID) Machine() []byte
Machine returns the 3-byte machine id part of the id. It's a runtime error to call this method with an invalid id.
func (id ID) MarshalJSON() ([]byte, error)
MarshalJSON implements encoding/json Marshaler interface
func (id ID) MarshalText() ([]byte, error)
MarshalText implements encoding/text TextMarshaler interface
func (id ID) Pid() uint16
Pid returns the process id part of the id. It's a runtime error to call this method with an invalid id.
func (id *ID) Scan(value interface{}) (err error)
Scan implements the sql.Scanner interface.
func (id ID) String() string
String returns a base32 hex lowercased with no padding representation of the id (char set is 0-9, a-v).
func (id ID) Time() time.Time
Time returns the timestamp part of the id. It's a runtime error to call this method with an invalid id.
func (id *ID) UnmarshalJSON(b []byte) error
UnmarshalJSON implements encoding/json Unmarshaler interface
func (id *ID) UnmarshalText(text []byte) error
UnmarshalText implements encoding/text TextUnmarshaler interface
func (id ID) Value() (driver.Value, error)
Value implements the driver.Valuer interface.