tools

package
v0.0.59 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2025 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNull           = errors.New("errNull")
	ErrTokenInvalid   = errors.New("ErrTokenInvalid")
	ErrDecodeToken    = errors.New("ErrDecodeToken")
	ErrUnmarshalToken = errors.New("ErrUnmarshalToken")
)
View Source
var GlobalDataMapChannel = make(map[int32]*cfg2.DataChannel, 0)
View Source
var GlobalDataMapInitInitialClothing = make(map[int32]*cfg2.DataInitialClothing, 0)
View Source
var GlobalDataMapInitInitialProps = make(map[int32]*cfg2.DataInitialProps, 0)
View Source
var GlobalDataMapItemRule = make(map[string]*cfg2.DataItemRule, 0)
View Source
var GlobalDataMapScene = make(map[int32]*cfg2.DataScene, 0)
View Source
var GlobalRandNameSlice = make([]string, 0)

Functions

func CreateDecimalByTimeStamp

func CreateDecimalByTimeStamp(timeStamp int64) float64

根据时间戳返回一个小于1的小数,时间越早值越大(2的14次方/现在距离1970的天数(精确到秒))

func DateToTm

func DateToTm(date string) int64

func DateYMHSIsBetween

func DateYMHSIsBetween(start, end string) bool

func DateYMHSIsBetweenTime

func DateYMHSIsBetweenTime(t time.Time, start, end string) bool

func GenerateDrawRandNum

func GenerateDrawRandNum(min, max, sum int) ([]int32, error)

GenerateDrawRandNum 区间:前闭后开 不能从0开始 会重复

func GetFirstDateOfWeek

func GetFirstDateOfWeek(now time.Time) (weekMonday time.Time)

func GetTimeWithHourAnchor

func GetTimeWithHourAnchor(anchorHour int32, days int32) time.Time

GetTimeWithHourAnchor 计算当前时间指定天数的指定时间 anchor (int): 锚点小时,格式为 5 days (int): 指定天数 return: 指定时间

func MakeCtxFromConnection

func MakeCtxFromConnection(conn ziface.IConnection) context.Context

func NowDateYMHSIsBetween

func NowDateYMHSIsBetween(start, end string) bool

func NowDateYMHSIsBetweenTime

func NowDateYMHSIsBetweenTime(t time.Time, start, end string) bool

func NowMonthStartEndTime

func NowMonthStartEndTime() (startTime, endTime time.Time)

获取本月开始结束时间

func NowMonthStartEndTimeUnix

func NowMonthStartEndTimeUnix() (startTime, endTime int64)

获取本月开始结束时间时分秒 2024-07-01 00:00:00 - 2024-07-31 23:59:59

func TimestampDurationDay

func TimestampDurationDay(start, end int64) int32

TimestampDurationDay 计算从start时间开始到end时间结束经过的天数(过24:00:00算一天)

func TimestampDurationDayWithAnchor

func TimestampDurationDayWithAnchor(start, end int64, anchorHour int32) int32

TimestampDurationDayWithAnchor 计算从start时间开始到end时间结束经过的天数 start: 开始时间戳 end: 结束时间戳 anchor (int): 锚点小时,格式为 5(凌晨5点为一天) 或 6(凌晨6点为一天) return: 经过的天数

func Unwrap

func Unwrap(num int64, retain int) float64

将int64恢复成正常的float64

func UnwrapToInt64

func UnwrapToInt64(num int64, retain int) int64

精准int64

func Wrap

func Wrap(num float64, retain int) int64

将float64转成精确的int64

func WrapToFloat64

func WrapToFloat64(num float64, retain int) float64

精准float64

Types

type FileTools

type FileTools struct {
}
var FileToolsObject FileTools

func (FileTools) ReadFile

func (f FileTools) ReadFile(fileName string) (readString string, err error)

type IDPool

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

func NewIDPool

func NewIDPool(maxID int) *IDPool

func (*IDPool) Allocate

func (p *IDPool) Allocate(id int) error

Allocate 分配一个 ID

func (*IDPool) Next

func (p *IDPool) Next() (int, error)

Next 获取下一个可用的 ID

func (*IDPool) Release

func (p *IDPool) Release(id int) error

Release 回收一个 ID

func (*IDPool) Reset

func (p *IDPool) Reset()

Reset reset

type InterfaceTools

type InterfaceTools struct {
}

* * InterfaceTools * @Description:

var InterfaceToolsObject InterfaceTools

* * InterfaceTools * @Description:

func (*InterfaceTools) IsNumber

func (i *InterfaceTools) IsNumber(value interface{}) bool

*

  • isNumber
  • @Description: 是否是数字类型的数据
  • @receiver i
  • @param value
  • @return bool

func (*InterfaceTools) ToString

func (i *InterfaceTools) ToString(value interface{}) string

/** * Strval * @Description: Strval 获取变量的字符串值,浮点型 3.0将会转换成字符串3, "3",非数值或字符类型的变量将会被转换成JSON格式字符串 * @param value * @return string */

type SliceTools

type SliceTools struct {
}

SliceTools /**

var SliceToolsObject SliceTools

SliceToolsObject /**

func (*SliceTools) ColumnBySlice

func (receiver *SliceTools) ColumnBySlice(mapParams []map[string]interface{}, keyParams string) []interface{}

func (SliceTools) DeleteEmptyAndUnique

func (h SliceTools) DeleteEmptyAndUnique(arr []string) []string

func (SliceTools) Difference

func (h SliceTools) Difference(slice1, slice2 []string) []string

func (SliceTools) DifferenceSliceByString

func (h SliceTools) DifferenceSliceByString(sliceOne []string, sliceTwo []string) []string

func (SliceTools) GetAddAndDelete

func (h SliceTools) GetAddAndDelete(old []int64, new []int64) ([]int64, []int64)

func (*SliceTools) GetIntersection

func (receiver *SliceTools) GetIntersection(sliceParams1 []string, sliceParams2 []string) []string

func (SliceTools) InArray

func (SliceTools) InArray(obj interface{}, target interface{}) bool

InArray 查找字符是否在数组中

func (*SliceTools) InSliceString

func (receiver *SliceTools) InSliceString(keyParams string, sliceParams []string) bool

func (SliceTools) InsertionSort

func (h SliceTools) InsertionSort(arr []int64)

func (SliceTools) RemoveDuplicateElement

func (h SliceTools) RemoveDuplicateElement(languages []string) []string

func (SliceTools) RemoveDuplicateElementLongInt

func (h SliceTools) RemoveDuplicateElementLongInt(languages []int64) []int64

func (SliceTools) SliceIntAsc

func (h SliceTools) SliceIntAsc(arr []int) []int

切片int 升序

func (SliceTools) SliceIntDesc

func (h SliceTools) SliceIntDesc(arr []int) []int

切片int 升序

func (SliceTools) ToSliceStringByInt

func (h SliceTools) ToSliceStringByInt(params []int) []string

func (SliceTools) ToSliceStringByInterface

func (receiver SliceTools) ToSliceStringByInterface(params []interface{}) []string

type VarTools

type VarTools struct {
}
var VarToolsObject VarTools

func (VarTools) InitInitialClothing added in v0.0.57

func (v VarTools) InitInitialClothing()

func (VarTools) InitInitialProps added in v0.0.57

func (v VarTools) InitInitialProps()

func (VarTools) InitItem added in v0.0.57

func (v VarTools) InitItem()

func (VarTools) InitRandName added in v0.0.14

func (v VarTools) InitRandName()

func (VarTools) InitScene added in v0.0.45

func (v VarTools) InitScene()

Directories

Path Synopsis
maptools
structtools

Jump to

Keyboard shortcuts

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