tools

package
v0.0.0-...-faf29f7 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2024 License: MIT Imports: 31 Imported by: 126

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AsString

func AsString(src interface{}) string

AsString 转成string

func Base64Decode

func Base64Decode(src string) ([]byte, error)

Base64Decode base64 解码

func Base64Encode

func Base64Encode(src []byte) string

Base64Encode base64 编码

func BuildDir

func BuildDir(absDir string) error

BuildDir 创建目录

func ByteToHex

func ByteToHex(data []byte) string

ByteToHex byte转16进制字符串

func CheckFileIsExist

func CheckFileIsExist(filename string) bool

CheckFileIsExist 检查目录是否存在

func CheckParam

func CheckParam(params ...string) bool

CheckParam 检测参数

func Compress

func Compress(files []*os.File, dest string) error

Compress 压缩文件 files 文件数组,可以是不同dir下的文件或者文件夹 dest 压缩文件存放地址

func ConvertString

func ConvertString(src string, tagCode string) string

ConvertString 系统转其他

func ConvertToString

func ConvertToString(src string, srcCode string, tagCode string) string

ConvertToString 字符集转换

func Copy

func Copy(dest []interface{}, src []interface{}) (result []interface{})

Copy 合并数组

func CopyFile

func CopyFile(src, des string) error

func DbcToSbc

func DbcToSbc(str string) string

DbcToSbc 全角转半角

func DecodeByte

func DecodeByte(data []byte, to interface{}) error

DecodeByte 解码二进制

func DeleteArray

func DeleteArray(src []interface{}, index int) (result []interface{})

DeleteArray 删除数组

func DeleteFile

func DeleteFile(absDir string) error

DeleteFile 删除文件或文件夹

func DeleteSlice

func DeleteSlice(slice interface{}, index int) (interface{}, error)

DeleteSlice 删除切片index

func DictSort

func DictSort(res []string) (str string)

DictSort 按字典顺序排序

func EncodeByte

func EncodeByte(data interface{}) ([]byte, error)

EncodeByte 编码二进制

func FormatInt

func FormatInt(list []int, seg string) string

FormatInt int数组转字符串

func FormatTime

func FormatTime(tm time.Time, forStr string) string

FormatTime 格式化时间

func GetClientIP

func GetClientIP(r *http.Request) (ip string)

GetClientIP 获取用户ip

func GetCurrentDirectory

func GetCurrentDirectory() string

GetCurrentDirectory 获取exe所在目录

func GetDay0

func GetDay0(timestamp int64) time.Time

GetDay0 获取给定日期的零点时间

func GetDayStr

func GetDayStr(tm time.Time) string

GetDayStr 获取日期字符串

func GetFuncName

func GetFuncName(f interface{}) string

GetFuncName 获取函数名

func GetGBK

func GetGBK(src string) string

GetGBK 获取gbk

func GetHour

func GetHour(timestamp int64) int

GetHour 当前时间向上取整点

func GetHour0

func GetHour0(timestamp int64) time.Time

GetHour0 获取向上整时时间

func GetJSONObj

func GetJSONObj(str string, out interface{}) error

GetJSONObj string convert to obj

func GetJSONStr

func GetJSONStr(obj interface{}, isFormat bool) string

GetJSONStr obj to json string

func GetLastDayCurrentTime

func GetLastDayCurrentTime(timestamp int64, offset int) time.Time

GetLastDayCurrentTime 获取offset天的现在时间:注意时区

func GetLocalIP

func GetLocalIP() (ip string)

GetLocalIP 获取内网ip

func GetLocalSystemLang

func GetLocalSystemLang(isSimple bool) (locale string)

GetLocalSystemLang 获取本地语言 (like:zh_CN.UTF-8)(simple:zh)

func GetLocalTime

func GetLocalTime(tm time.Time) time.Time

GetLocalTime 获取本地时间

func GetMd5String

func GetMd5String(s string) string

GetMd5String 生成32位md5字串

func GetModelPath

func GetModelPath() string

GetModelPath 获取程序运行目录

func GetMonth0

func GetMonth0(timestamp int64) time.Time

GetMonth0 获取给定时间的当月1号零点时间

func GetPathDirs

func GetPathDirs(absDir string) (re []string)

GetPathDirs 获取目录所有文件夹

func GetPathFiles

func GetPathFiles(absDir string) (re []string)

GetPathFiles 获取目录所有文件

func GetRandInt

func GetRandInt(min int, max int) int

GetRandInt 生成随机整数 digit:位数

func GetRandomString

func GetRandomString(n int) string

GetRandomString 生成随机字符串

func GetRangeNum

func GetRangeNum(digit int) int

GetRangeNum 生成随机整数 digit:位数

func GetRangeNumString

func GetRangeNumString(n int) string

GetRangeNumString 生成随机数字字符串

func GetSysTimeLayout

func GetSysTimeLayout() string

GetSysTimeLayout 获取系统时间的格式

func GetTimeStr

func GetTimeStr(tm time.Time) string

GetTimeStr 获取时间字符串

func GetTimeWeek

func GetTimeWeek(timestamp int64) int

GetTimeWeek 获取给定时间的星期

func GetTotalPageNum

func GetTotalPageNum(pageSize, totalCount int) int

GetTotalPageNum 获取总页数

func GetUtcDay0

func GetUtcDay0(tm time.Time) int64

GetUtcDay0 获取给定日期的零点时间

func GetUtcHour0

func GetUtcHour0(tm time.Time) int64

GetUtcHour0 获取向上整时时间

func GetUtcMinute0

func GetUtcMinute0(tm time.Time) int64

GetUtcMinute0 获取向上整时时间

func GetUtcTime

func GetUtcTime(tm time.Time) int64

GetUtcTime 获取本地时间戳

func GetUtcWeek0

func GetUtcWeek0(timestamp int64) int64

GetUtcWeek0 获取最近上个星期天的零点日期

func GetUtf8Len

func GetUtf8Len(str string) int

GetUtf8Len 获取中文字符的长度

func GetUtf8Str

func GetUtf8Str(str string) []rune

GetUtf8Str 中文字符切割时有问题。采用此方式不会有问题

func GetWeek0

func GetWeek0(timestamp int64) time.Time

GetWeek0 获取最近上个星期天的零点日期

func GetWwwIP

func GetWwwIP() (exip string)

GetWwwIP 获取公网IP地址

func Getenv

func Getenv(key string) string

Getenv 获取本地系统变量

func HexToBye

func HexToBye(hexStr string) []byte

HexToBye 16进制字符串转[]byte

func IsHan

func IsHan(str string) bool

IsHan 判断是否有中文

func IsIDCard

func IsIDCard(cardNo string) bool

IsIDCard 判断是否是18或15位身份证

func IsInternalType

func IsInternalType(t string) bool

IsInternalType 是否是内部类型

func IsKeywords

func IsKeywords(t string) bool

IsKeywords 是否是关键字

func IsMail

func IsMail(username string) (isMail bool)

IsMail 判断用户是否是邮件用户

func IsPhone

func IsPhone(mobileNum string) bool

IsPhone 判断是否是手机号

func IsRunTesting

func IsRunTesting() bool

IsRunTesting 判断是否在测试环境下使用

func IsUtf8

func IsUtf8(data []byte) bool

func IsZip

func IsZip(zipPath string) bool

IsZip 是否zip文件

func JSONDecode

func JSONDecode(obj interface{}) string

JSONDecode Json Decode

func JSONEncode

func JSONEncode(str string, out interface{}) error

JSONEncode string convert to obj

func JSONToForm

func JSONToForm(r *http.Request)

JSONToForm tag json str to form

func Md5Encoder

func Md5Encoder(src string) string

Md5Encoder md5 加密

func MinimumInt

func MinimumInt(rest []int) int

MinimumInt 查找int最小值

func MinimumString

func MinimumString(rest []string) string

MinimumString 查找字符串最小值

func MoveFile

func MoveFile(from, to string) error

MoveFile 移动文件或文件夹(/结尾)

func ReadFile

func ReadFile(fname string) (src []string)

ReadFile 读取文件

func ReadFileEx

func ReadFileEx(fname string) (src []byte)

ReadFileEx 读取文件

func RemoveMark

func RemoveMark(text string) string

RemoveMark 去掉标点符号

func Reverse

func Reverse(s string) string

Reverse 反转字符串

func SaveToFile

func SaveToFile(fname string, src []string, isClear bool) bool

SaveToFile 写入文件

func Sha1Encrypt

func Sha1Encrypt(str string) string

Sha1Encrypt SHA1加密

func StrToTime

func StrToTime(tStr, format string, timeZone *time.Location) time.Time

StrToTime 字符串转时间

func StringTimetoUnix

func StringTimetoUnix(timestr string) int64

StringTimetoUnix 给定字符串时间转换成本地时间戳

func Substr

func Substr(str string, start, length int) string

Substr 截取字符串 不包括str

func TimerByHour

func TimerByHour(f func())

TimerByHour 整点执行操作

func UnicodeEmojiCode

func UnicodeEmojiCode(s string) string

UnicodeEmojiCode Emoji表情转换

func UnicodeEmojiDecode

func UnicodeEmojiDecode(s string) string

UnicodeEmojiDecode Emoji表情解码

func UniqueID

func UniqueID() string

UniqueID 生成32位guid

func UnixToTime

func UnixToTime(timestamp int64) time.Time

UnixToTime 时间戳转换为time

func Unzip

func Unzip(archive, target string) error

Unzip 解压

func WriteFile

func WriteFile(fname string, src []string, isClear bool) bool

WriteFile 写入文件

func WriteFileEx

func WriteFileEx(fname string, src []byte, isClear bool) bool

WriteFile 写入文件

Types

type RawBytes

type RawBytes []byte

RawBytes ...

type Time

type Time struct {
	time.Time
}

Time json marsh 重写

func (Time) MarshalJSON

func (t Time) MarshalJSON() ([]byte, error)

MarshalJSON ...

func (Time) String

func (t Time) String() string

String ...

func (*Time) UnmarshalJSON

func (t *Time) UnmarshalJSON(data []byte) (err error)

UnmarshalJSON ...

Jump to

Keyboard shortcuts

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