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 ForEach[T any, V any](list []T, getValue func(item *T) V) []V
- func GetLocalIp() (string, error)
- 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 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()) chan bool
- 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
- func TruncateDay(t time.Time) time.Time
- func Validate(data any) error
- type Bus
- type BusCallBack
- type BusEventResult
- type BusOnResultFunc
- type HttpOptions
- type Map
- type Number
- type Response
- type Set
- type StringSet
- type ValidateError
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 GetLocalIp ¶ added in v0.12.8
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
循环定时,暂时启动后不能停止 @return cancel signal:cancel <- false
Types ¶
type Bus ¶
type Bus[T any] struct { // contains filtered or unexported fields }
事件总线 T:上下文泛型
func NewBus ¶
func NewBus[T any](onResult BusOnResultFunc[T]) *Bus[T]
type BusEventResult ¶ added in v0.12.13
type BusOnResultFunc ¶ added in v0.12.6
type BusOnResultFunc[T any] func(ctx T, event string, data any, allSuccess bool, details []BusEventResult)
type HttpOptions ¶ added in v0.12.4
type Map ¶
type Map[T any] struct { // contains filtered or unexported fields }
线程安全 map
type Response ¶ added in v0.12.3
func Get ¶ added in v0.12.3
func Get[T any](url string, options *HttpOptions) (*Response[T], error)
发送 get 请求 默认1分钟超时
type Set ¶ added in v0.12.0
type Set[T any] struct { // contains filtered or unexported fields }
type StringSet ¶ added in v0.5.0
type StringSet struct {
// contains filtered or unexported fields
}
线程安全
func NewStringSet ¶ added in v0.5.0
type ValidateError ¶ added in v0.13.0
func (ValidateError) Error ¶ added in v0.13.0
func (t ValidateError) Error() string
func (*ValidateError) Is ¶ added in v0.13.1
func (t *ValidateError) Is(target error) bool
Click to show internal directories.
Click to hide internal directories.