Documentation ¶
Index ¶
- Constants
- func Batch[T any, V any](fn func(T) V, ts []T) []V
- func BcryptCheck(password, hash string) bool
- func BcryptHash(password string) string
- func Complete[E comparable](a []E, b []E) bool
- func Contain[E comparable](e E, es ...E) bool
- func CopyStructFields(a interface{}, b interface{}, fields ...string) (err error)
- func Distinct[T comparable](ts []T) []T
- func DistinctAny[E any, K comparable](es []E, fn func(e E) K) []E
- func Filter[E, T any](es []E, fn func(e E) (T, bool)) []T
- func Generate() (string, string, string)
- func GenerateUserID() string
- func GenerateUserSig(ctx context.Context, userID string, sdkAppID int64, key string, expire int64) (string, error)
- func GetBeforeTime(day int) (int64, string, time.Time)
- func GetCurDayHalfTimeFormat() string
- func GetCurDayHalfTimestamp() int64
- func GetCurDayZeroTimeFormat() string
- func GetCurDayZeroTimestamp() int64
- func GetCurrentTimestampByMill() int64
- func GetCurrentTimestampByNano() int64
- func GetCurrentTimestampBySecond() int64
- func GetFuncName(skips ...int) string
- func GetTimeStampByFormat(datetime string) string
- func HashUserID(userID string) string
- func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int
- func IndexOf[E comparable](e E, es ...E) int
- func IsContain(target string, List []string) bool
- func IsContainInt(target int, List []int) bool
- func IsContainInt32(target int32, List []int32) bool
- func Keys[K comparable, V any](kv map[K]V) []K
- func Md5(s string, salt ...string) string
- func NewTimestamp(t time.Time) *timestamppb.Timestamp
- func Single[E comparable](a, b []E) []E
- func Slice[E any, T any](es []E, fn func(e E) T) []T
- func SliceSet[E comparable](es []E) map[E]struct{}
- func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{}
- func SliceToMap[E any, K comparable](es []E, fn func(e E) K) map[K]E
- func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V
- func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V
- func Sort[E Ordered](es []E, asc bool) []E
- func SortAny[E any](es []E, fn func(a, b E) bool)
- func Split2Int64Slice(s string) []int64
- func TimeNow() *time.Time
- func TimeStampChangeTimeStr(timeStamp int64) string
- func TimeStringFormatTimeTime(timeFormat string, timeSrc string) time.Time
- func TimeStringFormatTimeUnix(timeFormat string, timeSrc string) int64
- func TimeStringToTime(timeString string) (time.Time, error)
- func TimeStringToTimeTime(timeSrc string) time.Time
- func TimeToString(t time.Time) string
- func TimestampToTime(t *timestamppb.Timestamp) time.Time
- func UnixMillSecondToTime(millSecond int64) time.Time
- func UnixNanoSecondToTime(nanoSecond int64) time.Time
- func UnixSecondToTime(second int64) time.Time
- func Values[K comparable, V any](kv map[K]V) []V
- func Verify(id string, val string) bool
- type Cache
- type GoogleAuth
- type Ordered
Constants ¶
const ( TimeOffset = 8 * 3600 //8 hour offset HalfOffset = 12 * 3600 //Half-day hourly offset )
Variables ¶
This section is empty.
Functions ¶
func CopyStructFields ¶
copy a by b b->a
func GenerateUserSig ¶
func GenerateUserSig(ctx context.Context, userID string, sdkAppID int64, key string, expire int64) (string, error)
GenerateUserSig 生成用户签名
func GetBeforeTime ¶
GetBeforeTime 获取n天前的秒时间戳、日期时间戳 day为负则代表取前几天,为正则代表取后几天,0则为今天
func GetCurDayHalfTimeFormat ¶
func GetCurDayHalfTimeFormat() string
Get the formatted time at 12 o'clock of the day, the format is "2006-01-02_12-00-00"
func GetCurDayHalfTimestamp ¶
func GetCurDayHalfTimestamp() int64
Get the timestamp at 12 o'clock on the day
func GetCurDayZeroTimeFormat ¶
func GetCurDayZeroTimeFormat() string
Get the formatted time at 0 o'clock of the day, the format is "2006-01-02_00-00-00"
func GetCurDayZeroTimestamp ¶
func GetCurDayZeroTimestamp() int64
Get the timestamp at 0 o'clock of the day
func GetCurrentTimestampByMill ¶
func GetCurrentTimestampByMill() int64
Get the current timestamp by Mill
func GetCurrentTimestampByNano ¶
func GetCurrentTimestampByNano() int64
Get the current timestamp by Nano
func GetCurrentTimestampBySecond ¶
func GetCurrentTimestampBySecond() int64
Get the current timestamp by Second
func GetFuncName ¶
func GetTimeStampByFormat ¶
func IndexAny ¶
func IndexAny[E any, K comparable](e E, es []E, fn func(e E) K) int
IndexAny get the index of the element
func IsContainInt ¶
func IsContainInt32 ¶
func NewTimestamp ¶
func NewTimestamp(t time.Time) *timestamppb.Timestamp
func SliceSetAny ¶
func SliceSetAny[E any, K comparable](es []E, fn func(e E) K) map[K]struct{}
SliceSetAny slice to map[K]struct{}
func SliceToMap ¶
func SliceToMap[E any, K comparable](es []E, fn func(e E) K) map[K]E
SliceToMap slice to map
func SliceToMapAny ¶
func SliceToMapAny[E any, K comparable, V any](es []E, fn func(e E) (K, V)) map[K]V
SliceToMapAny slice to map (自定义类型)
func SliceToMapOkAny ¶
func SliceToMapOkAny[E any, K comparable, V any](es []E, fn func(e E) (K, V, bool)) map[K]V
SliceToMapOkAny slice to map (自定义类型, 筛选)
func Split2Int64Slice ¶
func TimeStringToTimeTime ¶
func TimeToString ¶
func TimestampToTime ¶
func TimestampToTime(t *timestamppb.Timestamp) time.Time
func UnixMillSecondToTime ¶
func UnixNanoSecondToTime ¶
Convert nano timestamp to time.Time type
func UnixSecondToTime ¶
Convert timestamp to time.Time type
Types ¶
type Cache ¶
type Cache[T comparable, K any] interface { Get(T) (K, error) MustGet(T) K }
type GoogleAuth ¶
type GoogleAuth struct { }
func NewGoogleAuth ¶
func NewGoogleAuth() *GoogleAuth
func (*GoogleAuth) GetCode ¶
func (this *GoogleAuth) GetCode(secret string) (string, error)
GetCode 获取动态码
func (*GoogleAuth) GetQrcode ¶
func (this *GoogleAuth) GetQrcode(secret string) string
GetQrcode 获取动态码二维码内容
func (*GoogleAuth) GetQrcodeUrl ¶
func (this *GoogleAuth) GetQrcodeUrl(secret string) string
GetQrcodeUrl 获取动态码二维码图片地址,这里是第三方二维码api
func (*GoogleAuth) VerifyCode ¶
func (this *GoogleAuth) VerifyCode(secret, code string) (bool, error)
VerifyCode 验证动态码