tool

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2021 License: Apache-2.0 Imports: 31 Imported by: 0

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 []byte) ([]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 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 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 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 FileIsExist

func FileIsExist(filename string) bool

FileIsExist 检查目录是否存在

func FormatInt

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

FormatInt int数组转字符串

func FormatTime

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

FormatTime 格式化时间

func GenerateRangeNum

func GenerateRangeNum(digit int) int

GenerateRangeNum 生成随机整数 digit:位数

func GenerateRangeNumString

func GenerateRangeNumString(n int) string

GenerateRangeNumString 生成随机数字字符串

func GetClientIP

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

GetClientIP 获取用户ip

func GetDay0

func GetDay0(timestamp int64) time.Time

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

func GetDayStr

func GetDayStr(tm time.Time) string

GetDayStr 获取日期字符串

func GetEnv

func GetEnv(key string) string

GetEnv 获取本地系统变量

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{})

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 GetMonth0

func GetMonth0(timestamp int64) time.Time

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

func GetPathDir

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

GetPathDirs 获取目录所有文件夹

func GetRandInt

func GetRandInt(min int, max int) int

GetRandInt 生成随机整数 digit:位数

func GetRandomString

func GetRandomString(n int) string

GetRandomString 生成随机字符串

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(now time.Time, timeZone *time.Location) int64

GetUtcDay0 获取offset 0点时间

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 HexToBye

func HexToBye(hexStr string) []byte

HexToBye 16进制字符串转[]byte

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 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{})

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 ReadFile

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

ReadFile 读取文件

func Reverse

func Reverse(s string) string

Reverse 反转字符串

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 写入文件

Types

type LocalTime added in v0.1.2

type LocalTime time.Time

自定义时间格式

func NewOftenTime added in v0.1.2

func NewOftenTime() LocalTime

func (LocalTime) MarshalBinary added in v0.1.2

func (p LocalTime) MarshalBinary() ([]byte, error)

func (LocalTime) MarshalJSON added in v0.1.2

func (p LocalTime) MarshalJSON() ([]byte, error)

func (LocalTime) MarshalText added in v0.1.2

func (p LocalTime) MarshalText() ([]byte, error)

func (LocalTime) String added in v0.1.2

func (p LocalTime) String() string

func (*LocalTime) UnmarshalBinary added in v0.1.2

func (p *LocalTime) UnmarshalBinary(data []byte) error

func (*LocalTime) UnmarshalJSON added in v0.1.2

func (p *LocalTime) UnmarshalJSON(data []byte) (err error)

func (*LocalTime) UnmarshalText added in v0.1.2

func (p *LocalTime) UnmarshalText(data []byte) (err error)

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