util

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2020 License: MIT Imports: 20 Imported by: 0

README

util

业务工具包

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenShortID added in v1.0.3

func GenShortID() (string, error)

GenShortID 生成一个id

func GenUUID

func GenUUID() string

GenUUID 生成随机字符串,eg: 76d27e8c-a80e-48c8-ad20-e5562e0f67e4

func GetAvatarURL added in v1.1.0

func GetAvatarURL(key string) string

GetAvatarURL user's avatar, if empty, use default avatar

func GetBytes added in v1.0.3

func GetBytes(key interface{}) ([]byte, error)

GetBytes interface 转 byte

func GetDate added in v1.1.0

func GetDate() string

GetDate 获取字符串日期

func GetDefaultAvatarURL added in v1.1.0

func GetDefaultAvatarURL() string

GetDefaultAvatarURL 获取默认头像

func GetLocalIP

func GetLocalIP() string

GetLocalIP 获取本地内网IP

func GetQiNiuPublicAccessURL added in v1.1.0

func GetQiNiuPublicAccessURL(path string) string

GetQiNiuPublicAccessURL 获取七牛资源的公有链接 无需配置bucket, 域名会自动到域名所绑定的bucket去查找

func GetRealIP added in v1.2.0

func GetRealIP(ctx *gin.Context) (ip string)

GetRealIP get user real ip

func GetReqID

func GetReqID(c *gin.Context) string

GetReqID 获取请求中的request_id

func GetShowTime added in v1.1.0

func GetShowTime(ts time.Time) string

GetShowTime 格式化时间

func GetTodayDateInt added in v1.1.0

func GetTodayDateInt() int

GetTodayDateInt 获取整形的日期

func IsEmpty added in v1.2.0

func IsEmpty(s string) bool

IsEmpty 是否是空字符串

func Md5 added in v1.1.0

func Md5(str string) (string, error)

Md5 字符串转md5

func RandomStr added in v1.2.0

func RandomStr(n int) string

RandomStr 随机字符串

func RegexpReplace added in v1.1.2

func RegexpReplace(reg, src, temp string) string

RegexpReplace ...

func StringSliceContains added in v1.1.0

func StringSliceContains(ss []string, s string) bool

StringSliceContains 字符串切片中是否包含另一个字符串 来自go源码 net/http/server.go

func StringSliceEqual added in v1.1.0

func StringSliceEqual(a, b []string) bool

StringSliceEqual 判断 string和slice 是否相等 使用了传统的遍历方式

func StringSliceReflectEqual added in v1.1.0

func StringSliceReflectEqual(a, b []string) bool

StringSliceReflectEqual 判断 string和slice 是否相等 因为使用了反射,所以效率较低,可以看benchmark结果

func StringToInt added in v1.1.0

func StringToInt(str string) (int, error)

StringToInt 字符串转int

func StringToInt64 added in v1.2.0

func StringToInt64(str string) (int64, error)

StringToInt64 字符串转int64

func StringToUint64 added in v1.1.0

func StringToUint64(str string) (uint64, error)

StringToUint64 字符串转uint64

func TimeLayout added in v1.1.0

func TimeLayout() string

TimeLayout 常用日期格式化模板

func TimeToShortString added in v1.1.0

func TimeToShortString(ts time.Time) string

TimeToShortString 时间转日期

func TimeToString added in v1.1.0

func TimeToString(ts time.Time) string

TimeToString 时间转字符串

func Uint64DeleteElemInSlice added in v1.1.0

func Uint64DeleteElemInSlice(i int, s []uint64) []uint64

Uint64DeleteElemInSlice 从slice删除元素 fast version, 会改变顺序 i:slice的索引值 s: slice

func Uint64DeleteElemInSliceWithOrder added in v1.1.0

func Uint64DeleteElemInSliceWithOrder(i int, s []uint64) []uint64

Uint64DeleteElemInSliceWithOrder 从slice删除元素 slow version, 保持原有顺序 i:slice的索引值 s: slice

func Uint64ShuffleSlice added in v1.1.0

func Uint64ShuffleSlice(a []uint64) []uint64

Uint64ShuffleSlice 对slice进行随机

func Uint64SliceReverse added in v1.1.0

func Uint64SliceReverse(a []uint64) []uint64

Uint64SliceReverse 对uint64 slice 反转

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