utils

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 7, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddrCheck

func AddrCheck(addr string) bool

func CreateToken

func CreateToken(userId int64) (string, error)

func GetDeviceID

func GetDeviceID(sid int64) (datacenterid, workerid int64)

获取数据中心ID和机器ID

func GetGenTime

func GetGenTime(sid int64) (t string)

获取创建ID时的时间字符串(精度:秒)

func GetGenTimestamp

func GetGenTimestamp(sid int64) (timestamp int64)

获取创建ID时的时间戳

func GetMQUrl

func GetMQUrl() string

func GetMysqlDSN

func GetMysqlDSN() string

func GetTimestamp

func GetTimestamp(sid int64) (timestamp int64)

获取时间戳

func GetTimestampStatus

func GetTimestampStatus() (state float64)

获取时间戳已使用的占比:范围(0.0 - 1.0)

func IsVideoFile

func IsVideoFile(header *multipart.FileHeader) bool

func MD5

func MD5(str string) string

MD5 use md5 to encode string

func MD5Bytes

func MD5Bytes(str []byte) string

func SHA256

func SHA256(str string) string

SHA256 use sha256 to encode string

Types

type Claims

type Claims struct {
	UserId int64 `json:"user_id"`
	jwt.StandardClaims
}

func CheckToken

func CheckToken(token string) (*Claims, error)

type SensitiveTrie

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

SensitiveTrie 敏感词前缀树

func NewSensitiveTrie

func NewSensitiveTrie() *SensitiveTrie

NewSensitiveTrie 构造敏感词前缀树实例

func (*SensitiveTrie) AddWord

func (st *SensitiveTrie) AddWord(sensitiveWord string)

AddWord 添加敏感词

func (*SensitiveTrie) AddWords

func (st *SensitiveTrie) AddWords(sensitiveWords []string)

AddWords 批量添加敏感词

func (*SensitiveTrie) FilterSpecialChar

func (st *SensitiveTrie) FilterSpecialChar(text string) string

FilterSpecialChar 过滤特殊字符

func (*SensitiveTrie) Match

func (st *SensitiveTrie) Match(text string) bool

Match 匹配敏感词

type Snowflake

type Snowflake struct {
	sync.Mutex
	// contains filtered or unexported fields
}

func NewSnowflake

func NewSnowflake(datacenterid, workerid int64) (*Snowflake, error)

func (*Snowflake) NextVal

func (s *Snowflake) NextVal() int64

timestamp + 数据中心id + 工作节点id + 自旋id

type TrieNode

type TrieNode struct {
	End bool // 标识是否最后一个节点
	// contains filtered or unexported fields
}

TrieNode 敏感词前缀树节点

func (*TrieNode) AddChild

func (tn *TrieNode) AddChild(c rune) *TrieNode

AddChild 前缀树添加字节点

func (*TrieNode) FindChild

func (tn *TrieNode) FindChild(c rune) *TrieNode

FindChild 前缀树查找字节点

Jump to

Keyboard shortcuts

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