utils

package
v1.0.10 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BitClear

func BitClear[T Int](val T, position int) T

BitClear 清理设置某一位的数值为0,从右到左方向

func BitSet

func BitSet[T Int](val T, position int) T

BitSet 填充设置某一位的数值为1,从右到左方向

func FormatGroupRoomID

func FormatGroupRoomID(groupID int64) string

FormatGroupRoomID 格式化群组聊天室房间号

func FormatPrivateRoomID

func FormatPrivateRoomID(userAID, userBID int64) string

FormatPrivateRoomID 格式化私人聊天室房间号

func FormatWorldRoomID added in v1.0.3

func FormatWorldRoomID(worldID int64) string

FormatWorldRoomID 格式化世界聊天室房间号

func IntBetween

func IntBetween[T Int](dest, from, to T) bool

IntBetween dest在指定范围内 是一个闭区间 from <= dest <= to

func IntLen

func IntLen[T Int](val T) int

func PasswordHash

func PasswordHash(pwd string) string

PasswordHash 封装的一个哈希密码的加密方法 使用双重MD5进行加密

func SortInt

func SortInt[T Int](a T, b T) (T, T)

SortInt 排序整型 返回的数据总是 a < b

func StringCut

func StringCut(data string, limit int) string

StringCut 裁剪字符串

func StringLen

func StringLen(data string) int

StringLen 返回字符串的长度,因为中文需要3个字节(byte),所以,我们使用rune来代替

func UUID added in v1.0.3

func UUID() string

UUID 全球唯一标识

Types

type Int

type Int interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64
}

Int 整型的一个泛型 包括 ~int | ~int8 | ~int16 | ~int32 | ~int64 | ~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64

Jump to

Keyboard shortcuts

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