ut

package module
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2021 License: MIT Imports: 17 Imported by: 0

README

ut为个人常用golang工具类和方法的集合

Documentation

Index

Constants

This section is empty.

Variables

View Source
var MaxRetrySmallError = errors.New("重试次数需要大于1")

Functions

func GetEndTimeOfToday added in v0.1.5

func GetEndTimeOfToday() time.Time

GetEndTimeOfToday 获取今日23点59分59秒

func GetFirstDateOfMonth added in v0.1.5

func GetFirstDateOfMonth() time.Time

GetFirstDateOfMonth 获取本月第一天0点

func GetFirstDateOfWeek added in v0.1.5

func GetFirstDateOfWeek() time.Time

GetFirstDateOfWeek 获取本周周一0点

func GetStartTimeOfToday added in v0.1.5

func GetStartTimeOfToday() time.Time

GetStartTimeOfToday 获取今日0点

func IsZeroOfUnderlyingType

func IsZeroOfUnderlyingType(x interface{}) bool

func ListStringToInterface

func ListStringToInterface(t []string) []interface{}

func MBuildFkUnwind added in v0.1.7

func MBuildFkUnwind(collection, localField, remoteField, remark string) []bson.D

MBuildFkUnwind 构建通用解构外键

func MBuildFkUnwindOfEmptyReturn added in v0.1.8

func MBuildFkUnwindOfEmptyReturn(collection, localField, remoteField, remark string) []bson.D

MBuildFkUnwindOfEmptyReturn preserveNullAndEmptyArrays 默认为false 不存在时则不返回 文档 https://docs.mongodb.com/manual/reference/operator/aggregation/unwind/

func MBuilderFk added in v0.1.7

func MBuilderFk(collection, localField, remoteField, remark string) bson.D

MBuilderFk 构建通用外键

func MGen2dSphere added in v0.1.4

func MGen2dSphere(k string) mongo.IndexModel

MGen2dSphere mongo 生成2dSphere索引

func MGenNormal added in v0.1.4

func MGenNormal(k string) mongo.IndexModel

MGenNormal mongo 生成普通索引

func MGenUnique added in v0.1.4

func MGenUnique(k string, sparse bool) mongo.IndexModel

MGenUnique mongo 生成唯一索引

func MTN added in v0.1.4

func MTN(instance interface{}) string

MTN 模型获取表名 使用 instanceToTableName 方法

func MUserFk added in v0.1.7

func MUserFk(local, remark string) bson.D

func MUserInfoFk added in v0.1.7

func MUserInfoFk(localField ...string) []bson.D

func NewFST

func NewFST(name string) funcTime

NewFST 方法计时器

func RandomInt

func RandomInt(start, end int) int

RandomInt 区间整数随机

func RandomStr

func RandomStr(n int) string

RandomStr 随机N位字符串(英文)

func RangeRandomIntSet

func RangeRandomIntSet(start int64, end int64, count int64) []int64

RangeRandomIntSet 范围随机正整数但不重复

func RemoveDuplicatesUnordered

func RemoveDuplicatesUnordered(elements []string) []string

RemoveDuplicatesUnordered 删除重复字符串但不保证排序

func RetryFunc added in v0.1.6

func RetryFunc(f func() error, maxRetryCount uint, interval time.Duration) error

RetryFunc 最大重试次数执行方法 函数返回error也会继续重试

func STN added in v0.1.4

func STN(modelName string) string

STN 模型字符串转表名 使用 strToTableName 方法

func SaveSliceToFiles added in v0.1.4

func SaveSliceToFiles(filePath string, values []interface{}, headers ...string) error

func StrToB58

func StrToB58(s string) string

func StrToB62

func StrToB62(s string) string

func StrToInt

func StrToInt(s string) int64

func StructCopy

func StructCopy(origin, newData interface{}) error

StructCopy 相同名称的struct field 进行copy

Types

This section is empty.

Jump to

Keyboard shortcuts

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