utils

package
v0.0.0-...-db099c4 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteElemFromUint64Slice

func DeleteElemFromUint64Slice(i int, a []uint64) []uint64

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

func DeleteElemOrderFromUint64Slice

func DeleteElemOrderFromUint64Slice(i int, a []uint64) []uint64

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

func GenShortId

func GenShortId() (string, error)

func GetAvatarUrl

func GetAvatarUrl(key string) string

user's avatar, if empty, use default avatar

func GetDate

func GetDate() string

func GetDefaultAvatarUrl

func GetDefaultAvatarUrl() string

func GetQiNiuPublicAccessUrl

func GetQiNiuPublicAccessUrl(path string) string

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

func GetReqID

func GetReqID(c *gin.Context) string

func GetShowTime

func GetShowTime(ts time.Time) string

格式化时间

func GetStaticImageUrl

func GetStaticImageUrl(key string) string

func GetTodayDateInt

func GetTodayDateInt() int

获取整形的日期

func Md5

func Md5(str string) (string, error)

字符串转md5

func StringSliceContains

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

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

func StringSliceEqual

func StringSliceEqual(a, b []string) bool

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

func StringSliceReflectEqual

func StringSliceReflectEqual(a, b []string) bool

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

func TimeLayout

func TimeLayout() string

func TimeToShortString

func TimeToShortString(ts time.Time) string

func TimeToString

func TimeToString(ts time.Time) string

func Uint64ShuffleSlice

func Uint64ShuffleSlice(a []uint64) []uint64

func Uint64SliceReverse

func Uint64SliceReverse(a []uint64) []uint64

uint64 slice 反转

Types

This section is empty.

Jump to

Keyboard shortcuts

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