util

package
v1.3.6 Latest Latest
Warning

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

Go to latest
Published: May 22, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LevelError 错误
	LevelError = iota
	// LevelWarning 警告
	LevelWarning
	// LevelInformational 提示
	LevelInformational
	// LevelDebug 除错
	LevelDebug
)

Variables

View Source
var Level = LevelDebug

Functions

func BuildConcat

func BuildConcat(str1, str2 string, DBType string) string

BuildConcat 根据数据库类型构建字符串连接表达式

func BuildLogger

func BuildLogger(level string)

BuildLogger 构建logger

func BuildRegexp

func BuildRegexp(search []string, prefix, suffix, condition string) string

BuildRegexp 构建用于SQL查询用的多条件正则

func ClearSession

func ClearSession(c *gin.Context)

ClearSession 清空session

func ContainsString

func ContainsString(s []string, e string) bool

ContainsString 返回list中是否包含

func ContainsUint

func ContainsUint(s []uint, e uint) bool

ContainsUint 返回list中是否包含

func CreatNestedFile

func CreatNestedFile(path string) (*os.File, error)

CreatNestedFile 给定path创建文件,如果目录不存在就递归创建

func DeleteSession

func DeleteSession(c *gin.Context, key string)

DeleteSession 删除session

func DotPathToStandardPath

func DotPathToStandardPath(path string) string

DotPathToStandardPath 将","分割的路径转换为标准路径

func EncodeUrl

func EncodeUrl(name string) string

对字符串进行安全转义

func Exists

func Exists(name string) bool

Exists reports whether the named file or directory exists.

func FillSlash

func FillSlash(path string) string

FillSlash 给路径补全`/`

func FormSlash

func FormSlash(old string) string

FormSlash 将path中的反斜杠'\'替换为'/'

func GenSnowflakeID

func GenSnowflakeID(startTime string, machineID int64) (int64, error)

生成 64 位的 雪花 ID

func Get24Time added in v1.2.4

func Get24Time(d time.Time) time.Time

获取某一天的23:59:59点时间

func GetFirstDateOfMonth

func GetFirstDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的第一天,即某月第一天的0点。如传入time.Now(), 返回当前月份的第一天0点时间。

func GetFirstDateOfYear

func GetFirstDateOfYear(d time.Time) time.Time

获取当年的最后一天

func GetLastDateOfMonth

func GetLastDateOfMonth(d time.Time) time.Time

获取传入的时间所在月份的最后一天,即某月最后一天的0点。如传入time.Now(), 返回当前月份的最后一天0点时间。

func GetLastDateOfYear

func GetLastDateOfYear(d time.Time) time.Time

获取当年的最后一天

func GetMonthDays

func GetMonthDays(year int, month int) int

GetMonthDays 获取某月有多少天

func GetSession

func GetSession(c *gin.Context, key string) interface{}

GetSession 获取session

func GetStrongPasswordString

func GetStrongPasswordString(l int) string

随机生成指定位数的大写字母和数字的组合

func GetStructTagValue

func GetStructTagValue(MyStruct interface{}, tagName, fieldName string) (string, error)

根据struct获取 tag 名称

func GetZeroTime

func GetZeroTime(d time.Time) time.Time

获取某一天的0点时间

func Init

func Init(startTime string, machineID int64) (err error)

func IsEmpty

func IsEmpty(name string) (bool, error)

IsEmpty 返回给定目录是否为空目录

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear 判断是否为闰年

func NewJsonTag

func NewJsonTag(tagName string) jsoniter.API

func ParamIsNull

func ParamIsNull(param string) error

请求参数不能为空

func RandStringRunes

func RandStringRunes(n int) string

RandStringRunes 返回随机字符串

func RelativePath

func RelativePath(name string) string

RelativePath 获取相对可执行文件的路径

func RemoveSlash

func RemoveSlash(path string) string

RemoveSlash 移除路径最后的`/`

func Replace

func Replace(table map[string]string, s string) string

Replace 根据替换表执行批量替换

func SetSession

func SetSession(c *gin.Context, list map[string]interface{})

SetSession 设置session

func SliceDifference

func SliceDifference(slice1, slice2 []string) []string

SliceDifference 求两个切片差集

func SliceIntersect

func SliceIntersect(slice1, slice2 []string) []string

SliceIntersect 求两个切片交集

func SplitPath

func SplitPath(path string) []string

SplitPath 分割路径为列表

func SqlLikePaste

func SqlLikePaste(keyStr string) string

sql like 验证

func StrSplitAny

func StrSplitAny(s string, seps string) []string

对字符串使用任意字符分隔

func TimeStringToGoTime added in v1.2.5

func TimeStringToGoTime(tm string) time.Time

时间格式字符串转换

Types

type Logger

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

Logger 日志

var GloablLogger *Logger

func Log

func Log() *Logger

Log 返回日志对象

func (*Logger) Debug

func (ll *Logger) Debug(format string, v ...interface{})

Debug 校验

func (*Logger) Error

func (ll *Logger) Error(format string, v ...interface{})

Error 错误

func (*Logger) Info

func (ll *Logger) Info(format string, v ...interface{})

Info 信息

func (*Logger) Panic

func (ll *Logger) Panic(format string, v ...interface{})

Panic 极端错误

func (*Logger) Println

func (ll *Logger) Println(prefix string, msg string)

Println 打印

func (*Logger) Warning

func (ll *Logger) Warning(format string, v ...interface{})

Warning 警告

Jump to

Keyboard shortcuts

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