utils

package
v1.1.45 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2024 License: GPL-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Decode added in v1.1.10

func Base64Decode(s string) string

func Base64Encode added in v1.1.10

func Base64Encode(s string) string

func BasePath

func BasePath() string

运行的程序所在目录

func BytesToString added in v1.1.43

func BytesToString(b []byte) string

BytesToString converts byte slice to string without a memory allocation.

func CompareVersion added in v1.1.7

func CompareVersion(ver, cVer string) int

CompareVersion 比较版本,-1:小于,0:相等,1:大于 v1.1.1 compare v1.2.1

func CurrentPath

func CurrentPath() string

当前目录(与运行程序所在目录无关)

func FileExt added in v1.1.9

func FileExt(file string) string

获取文件后缀

func FindStrBetweenStr added in v1.1.45

func FindStrBetweenStr(s string, left, right string) string

FindStrBetweenStr 查找left和right字符串中间的字符串

func FmtPageParams added in v1.1.7

func FmtPageParams(pageNum, pageSize int64) (int64, int64)

func GetLocalIP

func GetLocalIP() (ipv4 string, err error)

获取本机网卡IP

func GetRequestIp added in v1.1.7

func GetRequestIp(r *http.Request) string

returns request real ip.

func InStringArray added in v1.1.9

func InStringArray(s string, arr []string) bool

func Interface2Float64 added in v1.1.43

func Interface2Float64(d interface{}) float64

Interface2Float64 任意值转float64

func Interface2Int64 added in v1.1.19

func Interface2Int64(d interface{}) int64

Interface2Int64 任意值转int64

func InterfaceToSqlString added in v1.1.43

func InterfaceToSqlString(a interface{}) string

func IsExistPath added in v1.1.9

func IsExistPath(path string) bool

文件或目录是否存在

func LoopDo added in v1.1.44

func LoopDo(f func(), dur time.Duration) func()

LoopDo 重复执行

func LoopDoI added in v1.1.44

func LoopDoI(f func(int64), dur time.Duration) func()

LoopDoI 重复执行(执行包含序号i)

func Md5Sum added in v1.1.7

func Md5Sum(s string) string

func NewMd5Password added in v1.1.7

func NewMd5Password(password string, secret string) string

func NewRequestId

func NewRequestId() string

func RandCode added in v1.1.8

func RandCode(l int, chars []string) string

func RandFigureCode added in v1.1.8

func RandFigureCode(l int) string

func RandLetterCode added in v1.1.8

func RandLetterCode(l int) string

func RandLetterFigureCode added in v1.1.8

func RandLetterFigureCode(l int) string

func ReadYaml added in v1.1.7

func ReadYaml(data interface{}, yamlContent string) error

func ReadYamlFile added in v1.1.7

func ReadYamlFile(data interface{}, configPath string) error

func ScanEmbedFsDo added in v1.1.43

func ScanEmbedFsDo(embFs embed.FS, fn func(file string, path string) error) error

ScanEmbedFsDo 扫描文件操作

func ScopeCreateSQLv1916 added in v1.1.43

func ScopeCreateSQLv1916(scope *gorm.Scope)

ScopeCreateSQLv1916 使用gorm scope生成create sql和vars(适用于gorm v1.9.16版本) copy from gorm source code scope.SQL, scope.SQLVars

func ScopeUpdateSQLv1916 added in v1.1.44

func ScopeUpdateSQLv1916(scope *gorm.Scope)

ScopeUpdateSQLv1916 使用gorm scope生成update sql和vars(适用于gorm v1.9.16版本) copy from gorm source code scope.SQL, scope.SQLVars

func SliceInt64ToMap added in v1.1.44

func SliceInt64ToMap(src []int64) map[int64]bool

SliceInt64ToMap 切片转map(去重)

func StringToBytes added in v1.1.43

func StringToBytes(s string) []byte

StringToBytes converts string to byte slice without a memory allocation.

func TrueScopeRand added in v1.1.45

func TrueScopeRand(min int64, max int64) int64

TrueScopeRand 真随机数,范围随机,min<= V <max

Types

type BatchPointCostPrinter added in v1.1.45

type BatchPointCostPrinter struct {
	log.InvokeLog
	// contains filtered or unexported fields
}

BatchPointCostPrinter 批量点位耗时打印

func NewBatchPointCostPrinter added in v1.1.45

func NewBatchPointCostPrinter() *BatchPointCostPrinter

func (*BatchPointCostPrinter) AddPoint added in v1.1.45

func (printer *BatchPointCostPrinter) AddPoint(name string)

func (*BatchPointCostPrinter) Print added in v1.1.45

func (printer *BatchPointCostPrinter) Print(id string, ts ...*CostPoint)

type CostPoint added in v1.1.45

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

CostPoint 耗时点位信息

func NewCostPoint added in v1.1.45

func NewCostPoint(name string, ts ...time.Time) *CostPoint

Jump to

Keyboard shortcuts

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