Documentation
¶
Index ¶
- func Clamp[T Number](value T, min T, max T) T
- func Filter[T any](list []T, match func(item *T) bool) []T
- func Find[T any](list []T, match func(item *T) bool) (*T, int)
- func First[T any](list []T) *T
- func Floor(value float64, len int) float64
- func Includes[T any](list []T, match func(item *T) bool) bool
- func Intersection[T any](listA []T, listB []T, compare func(a *T, b *T) bool) []T
- func Join(list []string, separator string) string
- func Last[T any](list []T) *T
- func Listify[T, V any](obj map[string]T, toValue func(key string, value *T) V) []V
- func Map[T any, V any](list []T, getValue func(item *T) V) []V
- func Max[T any, V Number](list []T, getValue func(item *T) V) *T
- func Md5(buff []byte) string
- func Merge[T any](a1 []T, a2 []T) []T
- func Min[T any, V Number](list []T, getValue func(item *T) V) *T
- func Objectify[T any, V any](list []T, getKey func(item *T) string, getValue func(item *T) V) map[string]V
- func Ptr[T any](val T) *T
- func QueryString(params map[string]string) string
- func Random(min int, max int) int
- func RandomString(length int) string
- func Reduce[T any, V any](list []T, inter func(prev *V, cur *T, index int) *V, initValue *V) *V
- func Remove[T any](list []T, index int) []T
- func Round(value float64, len int) float64
- func SetInterval(duration time.Duration, cb func())
- func Sha1(buff []byte) string
- func Sort[T any](list []T, compare func(a *T, b *T) bool)
- func Sum[T any, V Number](list []T, getValue func(item *T) V) V
- func Trunc[T Number](value T, block T) T
- type Bus
- type BusCallBack
- type Logger
- type LoggerSession
- type Number
- type StringSet
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Find ¶
查找 slice 某项 @return 1:Item pointer,nil will be not find @return 2:item index,-1 will be not find
func Intersection ¶ added in v0.2.0
获取 slice 交集
func Objectify ¶
func Objectify[T any, V any](list []T, getKey func(item *T) string, getValue func(item *T) V) map[string]V
slice 转 map
func QueryString ¶ added in v0.3.1
object 排序后,转查询参数,不带?返回
func SetInterval ¶ added in v0.3.0
循环定时,暂时启动后不能停止
Types ¶
type Bus ¶
type Bus struct {
// contains filtered or unexported fields
}
func (*Bus) On ¶
func (t *Bus) On(event string, cb BusCallBack)
type BusCallBack ¶
type Logger ¶ added in v0.4.0
type Logger struct {
// contains filtered or unexported fields
}
func NewLogger ¶ added in v0.4.0
node:应用节点 addr:服务端地址 lv:4-debug 同时console 输出,3-info,2-warn,1-只打印 error
func (*Logger) NewSession ¶ added in v0.4.0
func (t *Logger) NewSession(seq string) *LoggerSession
type LoggerSession ¶ added in v0.4.0
type LoggerSession struct {
// contains filtered or unexported fields
}
func (*LoggerSession) Debug ¶ added in v0.4.0
func (t *LoggerSession) Debug(contents ...any)
func (*LoggerSession) Error ¶ added in v0.4.0
func (t *LoggerSession) Error(contents ...any)
func (*LoggerSession) Info ¶ added in v0.4.0
func (t *LoggerSession) Info(contents ...any)
func (*LoggerSession) Warn ¶ added in v0.4.0
func (t *LoggerSession) Warn(contents ...any)
type StringSet ¶ added in v0.5.0
type StringSet struct {
List []string
}
非线程安全
func NewStringSet ¶ added in v0.5.0
Click to show internal directories.
Click to hide internal directories.