niceid

package
v0.0.0-...-72d088b Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsNiceID

func IsNiceID(id []int64, filter Filter) bool

IsNiceID check id

Types

type Config

type Config struct {
	Prefix      []string           // 指定前缀
	Suffix      []string           // 指定后缀
	PrefixRange []map[string]int64 // 前缀范围
	SuffixRange []map[string]int64 // 后缀返回
	Contains    []string           // 模糊匹配
}

Config : ...

type Filter

type Filter struct {
	// contains filtered or unexported fields
}

Filter : ...

func NewFilter

func NewFilter(config *Config) *Filter

NewFilter create new config

func (*Filter) Contains

func (f *Filter) Contains(id []int64) bool

Contains 是否包含指定串

func (*Filter) HasPrefix

func (f *Filter) HasPrefix(id []int64) bool

HasPrefix 是否包含指定前缀

func (*Filter) HasSuffix

func (f *Filter) HasSuffix(id []int64) bool

HasSuffix 是否包含指定后缀

func (*Filter) Is2in4

func (f *Filter) Is2in4(id []int64) bool

Is2in4 任何连续4个字符中仅包含2个字符元素,如 1 9449 735

func (*Filter) IsBoom

func (f *Filter) IsBoom(id []int64) bool

IsBoom 是否包含炸弹,连续三位以上相同

func (*Filter) IsInPrefixRange

func (f *Filter) IsInPrefixRange(id []int64) bool

IsInPrefixRange 前缀是否在指定范围内

func (*Filter) IsInSuffixRange

func (f *Filter) IsInSuffixRange(id []int64) bool

IsInSuffixRange 后缀是否在指定范围内

func (*Filter) IsRound

func (f *Filter) IsRound(id []int64) bool

IsRound 是否是回旋结构,1357531

func (*Filter) IsSerial

func (f *Filter) IsSerial(id []int64) bool

IsSerial 是否开始或结尾包含连续三位数

func (*Filter) IsSerialInner

func (f *Filter) IsSerialInner(id []int64) bool

IsSerialInner 是否内部包含连续四位数

func (*Filter) IsTooFew

func (f *Filter) IsTooFew(id []int64) bool

IsTooFew 是否包含过少的元素,小于等于3个,认为包含元素过少

type GenResult

type GenResult struct {
	Normal []int64 // 普通ID
	Nice   []int64 // 靓号
	LastID int64   // 最后一个号码,下次可使用该号+1持续生成
}

GenResult : Result of NiceID::Gen

func Gen

func Gen(start int64, limit int64) *GenResult

Gen 从起始位置生成指定数量的ID

Jump to

Keyboard shortcuts

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