Documentation ¶
Index ¶
- Variables
- func Abs[T constraints.Integer | constraints.Float](x T) T
- func ArrayClone[T any](arr []T) []T
- func ArrayDel[T comparable](arr []T, Del T) []T
- func ArrayFirst[T any](arr []T) T
- func ArrayLast[T any](arr []T) T
- func ArrayMerge[T any](a ...[]T) []T
- func ArrayPos[T comparable](arr []T, item T) (pos int, ok bool)
- func ArrayRandom[T comparable](s []T) T
- func ArrayRandom2[T comparable](s []T) (int, T)
- func Bytes2String(b []byte) string
- func Colorize(s interface{}, c int, disabled bool) string
- func CopyTwoSlice[T any](s [][]T) (newSlice [][]T)
- func DeepEqual[T any](a, b T) bool
- func DeleteSliceItem[T comparable](list []T, value T) (newList []T)
- func FormatCaller(consoleWriter *zerolog_writer.ConsoleWriter, PathDirLevel int) func(i interface{}) string
- func FormatFloat(f float64, prec int, FillZero bool) string
- func GetCurrCaller(dirLevel ...int) string
- func GetParentCaller(dirLevel ...int) string
- func GetRandByRange(randNum float64, start float64, end float64) float64
- func GetStructTagName(s any, tagName string) (map[string]string, error)
- func HashCrc32(s []byte) uint32
- func HashFnv1A(s []byte) uint32
- func HttpGet(url string, header map[string]string) (int, []byte, error)
- func HttpPostForm(url string, data url.Values, header map[string]string) (int, []byte, error)
- func HttpPostJson(url string, bodyRaw string, header map[string]string) (int, []byte, error)
- func InArray[T comparable](arr []T, item T) bool
- func IsDigit(str string) bool
- func JsonCompression(jsonByte []byte) ([]byte, error)
- func MapMerge[K comparable, V any](m ...map[K]V) map[K]V
- func Max[T constraints.Ordered](n ...T) T
- func Md5(str string) string
- func Min[T constraints.Ordered](n ...T) T
- func Min2[T constraints.Ordered](n ...T) (index int, value T)
- func NumericStringSeparate(str string, n int, sep string) string
- func PathDirLevelCount(pathStr string) int
- func PathExists(path string) (bool, error)
- func PathRetainRight(pathStr string, n int) string
- func QueryUnescapeNum(str string, Num int) (string, error)
- func RandInt(min, max int) int
- func RandInt64(min, max int64) int64
- func RandOneByWight[T any, Wight constraints.Integer | constraints.Float](randNum float64, m []lo.Tuple2[Wight, T]) T
- func RunFuncName() string
- func RunFuncNameExt() string
- func Shuffle[T any](arr []T)
- func SliceRepeatItemMost[T comparable](list []T) (item T, num int)
- func SplitNumber(num int, n int) []int
- type ConfigToMysqlTargetStruct
- type CryptoCBCAES
- type DebugX
- func (s *DebugX) Allocs() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) AllocsSvg() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) AllocsTop() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) BlockSvg() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) BlockTop() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) Command(name string, arg ...string) (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) Goroutine() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) GoroutineSvg() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) GoroutineTop() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) Handle(ctx *gin.Context)
- func (s *DebugX) HandleMux(writer http.ResponseWriter, request *http.Request)
- func (s *DebugX) Heap() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) HeapSvg() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) HeapTop() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) MutexSvg() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) MutexTop() (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) Profile(d time.Duration) (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) ProfileSvg(d time.Duration) (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) ProfileTop(d time.Duration) (cmd string, stdout, stderr []byte, err error)
- func (s *DebugX) Register(router *gin.Engine)
- func (s *DebugX) RegisterMux(router *mux.Router)
- func (s *DebugX) SetGoCmdPath(p string) *DebugX
- func (s *DebugX) SetUrlPath(p string) *DebugX
- func (s *DebugX) Template() *template.Template
- type JSON2
- type LogRusHook
- type MongoID
- type MysqlSaveConfig
- func (s *MysqlSaveConfig) Add(defaultVal any) error
- func (s *MysqlSaveConfig) CreateTable() error
- func (s *MysqlSaveConfig) Get(rt any) error
- func (s *MysqlSaveConfig) GetType() string
- func (s *MysqlSaveConfig) Set(filedName string, defaultVal any) error
- func (s *MysqlSaveConfig) With2(Type string, TargetStruct ConfigToMysqlTargetStruct) MysqlSaveConfigWith2
- func (s *MysqlSaveConfig) WithTableNotes(TableNotes string) MysqlSaveConfigWith1
- type MysqlSaveConfigNew
- type MysqlSaveConfigWith1
- type MysqlSaveConfigWith2
- type PaddingType
- type RedisZSetLRU
- func (s *RedisZSetLRU) Add(Score float64, data interface{}, Expire time.Duration, MaxCacheNumber int64) error
- func (s *RedisZSetLRU) GetOneByIndex(out interface{}, index int64) (Score float64, err error)
- func (s *RedisZSetLRU) GetScoreMax(out interface{}) (Score float64, err error)
- func (s *RedisZSetLRU) GetScoreMin(out interface{}) (Score float64, err error)
Constants ¶
This section is empty.
Variables ¶
var Cron = cronT{
Yearly: "@yearly",
Annually: "@annually",
Monthly: "@monthly",
Weekly: "@weekly",
Daily: "@daily",
Midnight: "@midnight",
Hourly: "@hourly",
}
var FeiShu = &feishu{}
var String = &strT{}
var Time = &timeT{}
Functions ¶
func ArrayPos ¶
func ArrayPos[T comparable](arr []T, item T) (pos int, ok bool)
ArrayPos 获取item在arr中的索引位置
func DeleteSliceItem ¶
func DeleteSliceItem[T comparable](list []T, value T) (newList []T)
DeleteSliceItem 根据值删除切片一个元素 返回新切片
func FormatCaller ¶
func FormatCaller(consoleWriter *zerolog_writer.ConsoleWriter, PathDirLevel int) func(i interface{}) string
func FormatFloat ¶
FormatFloat 四舍五入格式化小数 f=小数,prec=保留位数,FillZero=小数位数不足是否填充0 true填充 false不填充
func GetRandByRange ¶
GetRandByRange 获取指定范围的随机数 根据 随机从 start-end之间获取一个数 根据 randNum 生成,只要randNum不变返回值就不会变
func GetStructTagName ¶
GetStructTagName 获取结构体的 tagName 标签值
func HttpPostForm ¶
HttpPostForm 请求 响应内容过大不建议使用此方法
func HttpPostJson ¶
HttpPostJson 请求 响应内容过大不建议使用此方法
func JsonCompression ¶
JsonCompression json压缩为1行
func NumericStringSeparate ¶
NumericStringSeparate 将字符串str中,连续数字个数超过 n 个的数字字符串,增加分隔符sep 函数介绍 utf8.DecodeRuneInString(arr[i])//输入字符串返回地1个字符的utf8编码 测试字符串:您好,您所查询的防伪码5003515624737308已在2022年08月07日10点46分39秒时间查询过第63次,此防伪码为正品码,若您此次为第一次查询,请谨防假冒! 测试结果:您好,您所查询的防伪码5-0-0-3-5-1-5-6-2-4-7-3-7-3-0-8已在2022年08月07日10点46分39秒时间查询过第63次,此防伪码为正品码,若您此次为第一次查询,请谨防假冒!, want
func PathDirLevelCount ¶
PathDirLevelCount 获取 pathStr 包含几级目录
func PathExists ¶
PathExists 判断一个文件或文件夹是否存在 输入文件路径,根据返回的bool值来判断文件或文件夹是否存在
func QueryUnescapeNum ¶
QueryUnescapeNum urldecode解码 并指定解码次数 num=要解码几次
0:未编码的字符串不需要处理 负数代表多解码了需要再编回来 正数多编码Num次需要解码Num次
func RandOneByWight ¶
func RandOneByWight[T any, Wight constraints.Integer | constraints.Float](randNum float64, m []lo.Tuple2[Wight, T]) T
RandOneByWight 根据权重随机
func Shuffle ¶
func Shuffle[T any](arr []T)
Shuffle 洗牌算法 主要思路为每次随机挑选一个值,放在数组末尾。然后在n-1个元素的数组中再随机挑选一个值,放在数组末尾,以此类推。 注意,一定要设置随机种子,否则每次返回的值是一样的。
func SliceRepeatItemMost ¶
func SliceRepeatItemMost[T comparable](list []T) (item T, num int)
SliceRepeatItemMost 切片中重复元素最多的元素
Types ¶
type ConfigToMysqlTargetStruct ¶
type ConfigToMysqlTargetStruct interface {
Default() any
}
type CryptoCBCAES ¶
type CryptoCBCAES struct {
// contains filtered or unexported fields
}
AES 加密算法实现 示例
func main() { ase, err := NewCryptoAES([]byte("hgfedcba87654321")) if err != nil { log.Fatalln(err) } src := []byte("19999999999999999999999中文1111111") log.Println("原文", string(src)) dst := ase.Encrypt(src) log.Println("密文", string(dst)) dst2 := ase.Decrypt(dst) log.Println("解密", string(dst2)) }
func NewCryptoCBCAES ¶
func NewCryptoCBCAES(key []byte, paddingType PaddingType) (*CryptoCBCAES, error)
type DebugX ¶
func (*DebugX) BlockSvg ¶
BlockSvg block含义是阻塞事件,协程抢锁或者管道的读写阻塞等,都会导致协程的阻塞, 协程阻塞时会记录阻塞时间点cputick,解除阻塞时同样记录时间点cputick,以此计算出协程阻塞时间,同时在解除阻塞时记录调用栈。 mutex含义是锁持有事件,在释放锁时记录时间以及调用栈。
func (*DebugX) GoroutineSvg ¶
GoroutineSvg 所有当前 goroutines 的堆栈跟踪
func (*DebugX) GoroutineTop ¶
func (*DebugX) HandleMux ¶
func (s *DebugX) HandleMux(writer http.ResponseWriter, request *http.Request)
func (*DebugX) HeapSvg ¶
HeapSvg 查看存活对象的内存分配, 内存的指标可通过heap或者allocs查看,这两个指标采样的数据是一样, 但是heap可以用来采样存活对象的内存分配(采样前可运行GC,这样剩下的都是存活对象了)。 线越粗说明该调用栈内存分配越多
func (*DebugX) ProfileSvg ¶
ProfileSvg 分析程序热点,比如发现程序中的死循环。 开启之后,会定时记录当然程序执行点(就是程序正在执行哪一行代码)以及调用栈,采集一段时间之后(默认30秒), 根据这些数据是不是就能分析出来热点代码 线越粗说明该调用cpu耗时越多
func (*DebugX) ProfileTop ¶
type JSON2 ¶
type JSON2 struct {
// contains filtered or unexported fields
}
JSON2 包装一个类型使其直json编解码 可用于 go-redis set一个struct 或 scan
func (*JSON2) MarshalBinary ¶
MarshalBinary 编码函数
func (*JSON2) UnmarshalBinary ¶
UnmarshalBinary 解码函数
type LogRusHook ¶
type LogRusHook struct {
PathLevel int //输出的目录层级 默认3
}
LogRusHook logrus的内容标准hook
func NewLogRusHook ¶
func NewLogRusHook() LogRusHook
type MongoID ¶
func (MongoID) ToRawURLBase64 ¶
ToRawURLBase64 转 RawURLEncoding,结果16个字符
type MysqlSaveConfig ¶
type MysqlSaveConfig struct { Type string //类型 TableNotes string //表注释 TableName string //表明 DB *gorm.DB TargetStruct ConfigToMysqlTargetStruct }
MysqlSaveConfig 将程序得配置信息存储到mysql
func (*MysqlSaveConfig) Add ¶
func (s *MysqlSaveConfig) Add(defaultVal any) error
Add 将结构体 configToMysql 写入mysql
func (*MysqlSaveConfig) GetType ¶
func (s *MysqlSaveConfig) GetType() string
func (*MysqlSaveConfig) Set ¶
func (s *MysqlSaveConfig) Set(filedName string, defaultVal any) error
Set 强制更新指定的字段
func (*MysqlSaveConfig) With2 ¶
func (s *MysqlSaveConfig) With2(Type string, TargetStruct ConfigToMysqlTargetStruct) MysqlSaveConfigWith2
func (*MysqlSaveConfig) WithTableNotes ¶
func (s *MysqlSaveConfig) WithTableNotes(TableNotes string) MysqlSaveConfigWith1
type MysqlSaveConfigNew ¶
type MysqlSaveConfigNew interface { With2(Type string, TargetStruct ConfigToMysqlTargetStruct) MysqlSaveConfigWith2 WithTableNotes(TableNotes string) MysqlSaveConfigWith1 }
func NewMysqlSaveConfig ¶
func NewMysqlSaveConfig(TableName string, DB *gorm.DB) MysqlSaveConfigNew
type MysqlSaveConfigWith1 ¶
type MysqlSaveConfigWith1 interface {
CreateTable() error
}
type MysqlSaveConfigWith2 ¶
type RedisZSetLRU ¶
type RedisZSetLRU struct {
// contains filtered or unexported fields
}
RedisZSetLRU 基于redis Zset实现 lru缓存 RedisFreshDataCache 最新数据缓存,自动淘汰就数据 使用场景 如:缓存用户最后发送的5条消息,超过5条则自动删除,用户30分钟未发消息则会删除所有消息
func NewRedisZSetLRU ¶
func NewRedisZSetLRU(rdb *redis.Client, RedisKey string) *RedisZSetLRU
func (*RedisZSetLRU) Add ¶
func (s *RedisZSetLRU) Add(Score float64, data interface{}, Expire time.Duration, MaxCacheNumber int64) error
Add 添加 //过期时间 //最大缓存个数
func (*RedisZSetLRU) GetOneByIndex ¶
func (s *RedisZSetLRU) GetOneByIndex(out interface{}, index int64) (Score float64, err error)
GetOneByIndex 根据下标获取一条数据
func (*RedisZSetLRU) GetScoreMax ¶
func (s *RedisZSetLRU) GetScoreMax(out interface{}) (Score float64, err error)
GetScoreMax 获取分值最大的数据
func (*RedisZSetLRU) GetScoreMin ¶
func (s *RedisZSetLRU) GetScoreMin(out interface{}) (Score float64, err error)
GetScoreMin 获取分值最小的数据
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
fsdef
|
|
Package s2m 目的:go-redis库 HMSet 将一个 map[string]string 类型的值设置到redis, HGetAll 获取hash中的所有值返回 map[string]string 类型的数据, 此包主要用于简化使用以上两个函数的复杂性,将一个struct体写入到一个redis hash数据类型,或将HGetAll的返回值解析到redis
|
Package s2m 目的:go-redis库 HMSet 将一个 map[string]string 类型的值设置到redis, HGetAll 获取hash中的所有值返回 map[string]string 类型的数据, 此包主要用于简化使用以上两个函数的复杂性,将一个struct体写入到一个redis hash数据类型,或将HGetAll的返回值解析到redis |
Package linkedhashmap is a map that preserves insertion-order.
|
Package linkedhashmap is a map that preserves insertion-order. |