ids

package
v1.1.23 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package ids 唯一标识.

包括ID和IDS.

Index

Examples

Constants

This section is empty.

Variables

View Source
var ErrBytesSize = errors.New("字节码长度不够")

ErrBytesSize 长度不够.

Functions

This section is empty.

Types

type ID

type ID [16]byte

ID 唯一标识.

func Bytes

func Bytes(bs []byte) (id ID)

Bytes 字节码转换ID.

func Hash

func Hash(bs []byte) ID

Hash 摘要ID.

func Ints

func Ints(a, b uint64) ID

Ints 两个uint64转换ID.

func Machine

func Machine(apps ...string) ID

Machine 机器ID.

func New

func New() ID

New 新建ID.

func Short

func Short(id string) (ID, error)

Short ID转换ID.

Example
package main

import (
	"fmt"

	"gitee.com/xuender/oils/ids"
)

func main() {
	fmt.Println(ids.Short("mxSR7WeTuKA8tmEyQhoZU"))

}
Output:

mxSR7WeTuKA8tmEyQhoZU <nil>

func UUID

func UUID(id string) (ID, error)

UUID 转换ID.

func (ID) Bytes added in v1.0.6

func (id ID) Bytes() []byte

Bytes 字节码.

func (*ID) Load added in v1.0.17

func (id *ID) Load(bs []byte) error

Load 加载字节码.

func (ID) Prefix

func (id ID) Prefix(prefix []byte) []byte

Prefix 增加前缀.

func (ID) String

func (id ID) String() string

String 转换短字符串.

func (ID) UUID

func (id ID) UUID() string

UUID 转换字符串.

type IDS

type IDS map[ID]struct{}

IDS ID列表.

func Intersection

func Intersection(elems ...IDS) IDS

Intersection 交集.

func NewIDS

func NewIDS(elems ...ID) IDS

NewIDS 新建IDS.

func Union

func Union(elems ...IDS) IDS

Union 合集.

func Unmarshal added in v1.0.16

func Unmarshal(bs []byte) (IDS, error)

Unmarshal 反序列化.

func (IDS) Add

func (is IDS) Add(elems ...ID) IDS

Add 增加ID.

func (IDS) AddBytes

func (is IDS) AddBytes(data ...[]byte) IDS

AddBytes 追加ID.

func (IDS) AddIDS

func (is IDS) AddIDS(elem IDS) IDS

AddIDS 增加IDS.

func (IDS) All

func (is IDS) All(elems ...ID) bool

All 包含全部ID.

func (IDS) AllIDS

func (is IDS) AllIDS(elem IDS) bool

AllIDS 包含IDS全部ID.

func (IDS) Any

func (is IDS) Any(elems ...ID) bool

Any 包含任意.

func (IDS) AnyIDS

func (is IDS) AnyIDS(elem IDS) bool

AnyIDS 包含IDS任意ID.

func (IDS) Bytes

func (is IDS) Bytes() [][]byte

Bytes IDS装换字节码.

func (IDS) Complement

func (is IDS) Complement(elems ...IDS) IDS

Complement 补集.

func (IDS) Del

func (is IDS) Del(elems ...ID) IDS

Del 删除ID.

func (IDS) DelIDS

func (is IDS) DelIDS(elems IDS) IDS

DelIDS 删除IDS.

func (IDS) Has

func (is IDS) Has(id ID) bool

Has 包含.

func (IDS) Marshal added in v1.0.16

func (is IDS) Marshal() []byte

Marshal 序列化.

func (IDS) Slice

func (is IDS) Slice() []ID

Slice 转换切片.

Jump to

Keyboard shortcuts

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