utils

package
v0.0.0-...-ed667ed Latest Latest
Warning

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

Go to latest
Published: May 24, 2021 License: Apache-2.0 Imports: 20 Imported by: 0

README

gokits

Golang 工具库

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// GZipMinSize 要启用gzip的最小值
	GZipMinSize = 1024
)

Functions

func AESDecryptData

func AESDecryptData(keystr, hexSrc string) string

AESDecryptData AESDecryptData

func AESEncryptData

func AESEncryptData(keystr, src string) string

AESEncryptData AESEncryptData

func Bool

func Bool(i bool) *bool

func BoolToByte

func BoolToByte(b bool) byte

BoolToByte bool to byte

func Byte

func Byte(i byte) *byte

func ByteToBool

func ByteToBool(b byte) bool

ByteToBool byte to bool

func Float64

func Float64(i float64) *float64

func FormatNumberToShortString

func FormatNumberToShortString(number int64) string

FormatNumberToShortString 数字格式化为短字符串,如 10000 = 1万

func FromGzip

func FromGzip(data []byte) (bs []byte, err error)

FromGzip from gzip

func FromGzipToJSON

func FromGzipToJSON(data []byte, obj interface{}) (err error)

FromGzipToJSON from gzip json

func GenRandomString

func GenRandomString(n int, randomRange []string) string

GenRandomString 生成随机字符串

func GetCurrMilliTs

func GetCurrMilliTs() int64

GetCurrMilliTs 获取当前时间戳

func GetLocalTime

func GetLocalTime() *time.Time

GetLocalTime get local time

func GetNextDayZeroTs

func GetNextDayZeroTs() int64

GetNextDayZeroTs 获取下一天的0点时间戳

func GetTimeByTs

func GetTimeByTs(ts int64) time.Time

获取指定时间戳的时间

func GetUTCTime

func GetUTCTime() *time.Time

GetUTCTime get utc time

func GetZeroTime

func GetZeroTime() time.Time

GetZeroTime 获取当天0点时间

func GetZeroTimeOf

func GetZeroTimeOf(t time.Time) time.Time

GetZeroTimeOf 获取指定日期的0点时间

func HmacSha1

func HmacSha1(message, secret string) string

HmacShal HmacShal

func Int32

func Int32(i int32) *int32

func Int64

func Int64(i int64) *int64

func IsEmpty

func IsEmpty(val interface{}) bool

IsEmpty 判断是否为空

func IsInArray

func IsInArray(arr []string, val string) bool

InArray 判断指定数组中包含指定项

func IsNumber

func IsNumber(s string) bool

IsNumber is number

func JSONStringToMap

func JSONStringToMap(jsonStr string) (map[string]interface{}, error)

JSONStringToMap json string to map

func MD5String

func MD5String(b []byte) string

MD5String md5

func ParseQueries

func ParseQueries(url string) map[string]string

func QueryEscape

func QueryEscape(s string) string

func QueryUnescape

func QueryUnescape(s string) (string, error)

func RandString

func RandString(l int) string

RandString rand string

func SleepRandomTime

func SleepRandomTime(maxSleepTime time.Duration)

SleepRandomTime 随机 sleep 时间

func String

func String(s string) *string

func StringToFloat64

func StringToFloat64(str string) (value float64)

func StringToInt32

func StringToInt32(val string) (value int32)

func StringToInt64

func StringToInt64(val string) (value int64)

func Time

func Time(t time.Time) *time.Time

func TimeAgoInWords

func TimeAgoInWords(ts int64) string

TimeAgoInWords 多久之前

func TimeFormat

func TimeFormat(layout string, dateTime time.Time) string

TimeFormat 日期格式化: yyyy-MM-dd HH:mm:ss

func ToGzip

func ToGzip(bs []byte) (gziped bool, data []byte, err error)

ToGzip gzip

func ToGzipJSON

func ToGzipJSON(obj interface{}) (gziped bool, data []byte, err error)

ToGzipJSON 转换成json并gzip

func ToJSONString

func ToJSONString(data interface{}) string

ToJSONString to json string

func ToPercent

func ToPercent(f float64) string

ToPercent to percent

func ToTime

func ToTime(layout, value string) *time.Time

ToTime 时间字符串转 Time

func TsToCn

func TsToCn(ts int32) string

TsToCn 获取时间(60s->1分钟,60分钟->1小时)

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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