common

package
v1.2.82 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeepCopyMap

func DeepCopyMap(value interface{}) interface{}

DeepCopyMap 复制返回数组

func IndexLastStr

func IndexLastStr(str, sep string) int

IndexLastStr 获取最后出现字符串的下标 return 找不到返回 -1

func JsonStrToStrArray

func JsonStrToStrArray(a string) string

字符串数组: a1,a2,a3转["a1","a2","a3"]

func Md5

func Md5(req string) string

Md5 md5

func ObjToBool

func ObjToBool(obj interface{}, e ...*Error) bool

func ObjToCeilFloat64

func ObjToCeilFloat64(obj interface{}, e ...*Error) float64

向上取整

func ObjToCeilInt

func ObjToCeilInt(obj interface{}, e ...*Error) int

向上取整

func ObjToCeilInt64

func ObjToCeilInt64(obj interface{}, e ...*Error) int64

向上取整

func ObjToFloat64

func ObjToFloat64(obj interface{}, e ...*Error) float64

func ObjToInt

func ObjToInt(obj interface{}, e ...*Error) int

func ObjToInt64

func ObjToInt64(obj interface{}, e ...*Error) int64

func ObjToStr

func ObjToStr(obj interface{}) string

func ObjToTime added in v1.1.6

func ObjToTime(obj interface{}, e ...*Error) *time.Time

func Rand

func Rand(count int) int

Rand 随机数

func RandX

func RandX(small int, max int) int

RandX 随机数范围

func Random

func Random() float64

func Round

func Round(f float64, n int) float64

Round 浮点数四舍五入保留小数

func StrArrayToJsonStr

func StrArrayToJsonStr(a string) string

字符串数组: a1,a2,a3转["a1","a2","a3"]

func StrFirstToUpper

func StrFirstToUpper(str string) string

StrFirstToUpper 字符串首字符大写

func StrLd

func StrLd(s, t string, ignoreCase bool) int

StrLd 相似度计算 ld compares two strings and returns the levenshtein distance between them.

func StrToInt

func StrToInt(s string) (int, error)

字符串转int

func Substr

func Substr(str string, start int, length int) string

Substr 字符串截取

func Time2Str added in v1.2.64

func Time2Str(t time.Time, qu ...interface{}) string

时间转字符串,第二个参数支持1-5对应显示年月日时分秒

Types

type ContextBase

type ContextBase struct {
	// contains filtered or unexported fields
}

func (*ContextBase) GetTag

func (that *ContextBase) GetTag() string

唯一标志

type Error

type Error struct {
	Logger *logrus.Logger
	// contains filtered or unexported fields
}

Error 框架层处理错误

func (*Error) GetError

func (that *Error) GetError() error

func (*Error) SetError

func (that *Error) SetError(err error)

type Map

type Map map[string]interface{}

hotime的常用map

func ObjToMap

func ObjToMap(obj interface{}, e ...*Error) Map

仅限于hotime.Slice

func ObjToMapArray

func ObjToMapArray(obj interface{}, e ...*Error) []Map

func StrToMap

func StrToMap(string string) Map

转换为Map

func (Map) Delete

func (that Map) Delete(key string)

删除接口

func (Map) Get

func (that Map) Get(key string, err ...*Error) interface{}

func (Map) GetBool

func (that Map) GetBool(key string, err ...*Error) bool

func (Map) GetCeilFloat64

func (that Map) GetCeilFloat64(key string, err ...*Error) float64

获取向上取整float64

func (Map) GetCeilInt

func (that Map) GetCeilInt(key string, err ...*Error) int

获取向上取整Int

func (Map) GetCeilInt64

func (that Map) GetCeilInt64(key string, err ...*Error) int64

获取向上取整Int64

func (Map) GetFloat64

func (that Map) GetFloat64(key string, err ...*Error) float64

获取Float64

func (Map) GetInt

func (that Map) GetInt(key string, err ...*Error) int

获取Int

func (Map) GetInt64

func (that Map) GetInt64(key string, err ...*Error) int64

获取Int

func (Map) GetMap

func (that Map) GetMap(key string, err ...*Error) Map

func (Map) GetSlice

func (that Map) GetSlice(key string, err ...*Error) Slice

func (Map) GetString

func (that Map) GetString(key string, err ...*Error) string

获取string

func (Map) GetTime added in v1.1.6

func (that Map) GetTime(key string, err ...*Error) *time.Time

func (Map) JsonToMap

func (that Map) JsonToMap(jsonStr string, err ...*Error)

func (*Map) Pointer

func (that *Map) Pointer() *Map

func (Map) Put

func (that Map) Put(key string, value interface{})

增加接口

func (Map) RangeSort added in v1.1.6

func (that Map) RangeSort(callback func(k string, v interface{}) (isEnd bool))

func (Map) ToJsonString

func (that Map) ToJsonString() string

func (Map) ToStruct

func (that Map) ToStruct(stct interface{})

请传递指针过来

type Obj

type Obj struct {
	Data interface{}
	Error
	ContextBase
}

对象封装方便取用

func (*Obj) Put

func (that *Obj) Put(data interface{})

func (*Obj) ToCeilFloat64

func (that *Obj) ToCeilFloat64(err ...*Error) float64

ToCeilFloat64 获取向上取整float64

func (*Obj) ToCeilInt

func (that *Obj) ToCeilInt(err ...*Error) int

获取向上取整Int

func (*Obj) ToCeilInt64

func (that *Obj) ToCeilInt64(err ...*Error) int64

获取向上取整Int64

func (*Obj) ToFloat64

func (that *Obj) ToFloat64(err ...Error) float64

func (*Obj) ToInt

func (that *Obj) ToInt(err ...Error) int

func (*Obj) ToInt64

func (that *Obj) ToInt64(err ...Error) int64

func (*Obj) ToMap

func (that *Obj) ToMap(err ...Error) Map

func (*Obj) ToMapArray

func (that *Obj) ToMapArray(err ...Error) []Map

func (*Obj) ToObj

func (that *Obj) ToObj() interface{}

func (*Obj) ToSlice

func (that *Obj) ToSlice(err ...Error) Slice

func (*Obj) ToStr

func (that *Obj) ToStr() string

func (*Obj) ToTime added in v1.1.6

func (that *Obj) ToTime(err ...Error) *time.Time

type Slice

type Slice []interface{}

func ObjToSlice

func ObjToSlice(obj interface{}, e ...*Error) Slice

仅限于hotime.Slice

func StrToSlice

func StrToSlice(string string) Slice

转换为Slice

func (Slice) Get

func (that Slice) Get(key int, err ...*Error) interface{}

func (Slice) GetBool

func (that Slice) GetBool(key int, err ...*Error) bool

func (Slice) GetCeilFloat64

func (that Slice) GetCeilFloat64(key int, err ...*Error) float64

GetCeilFloat64 获取向上取整float64

func (Slice) GetCeilInt

func (that Slice) GetCeilInt(key int, err ...*Error) int

GetCeilInt 获取向上取整Int

func (Slice) GetCeilInt64

func (that Slice) GetCeilInt64(key int, err ...*Error) int64

GetCeilInt64 获取向上取整Int64

func (Slice) GetFloat64

func (that Slice) GetFloat64(key int, err ...*Error) float64

GetFloat64 获取Float64

func (Slice) GetInt

func (that Slice) GetInt(key int, err ...*Error) int

GetInt 获取Int

func (Slice) GetInt64

func (that Slice) GetInt64(key int, err ...*Error) int64

GetInt64 获取Int

func (Slice) GetMap

func (that Slice) GetMap(key int, err ...*Error) Map

func (Slice) GetSlice

func (that Slice) GetSlice(key int, err ...*Error) Slice

func (Slice) GetString

func (that Slice) GetString(key int, err ...*Error) string

GetString 获取string

func (Slice) GetTime added in v1.1.6

func (that Slice) GetTime(key int, err ...*Error) *time.Time

func (Slice) Put

func (that Slice) Put(key int, value interface{})

func (Slice) ToJsonString

func (that Slice) ToJsonString() string

Jump to

Keyboard shortcuts

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