Documentation ¶
Overview ¶
Package ext 反射扩展
Index ¶
- Constants
- Variables
- func All[T interface{}](slice []T, where func(t T) bool) bool
- func Any[T interface{}](slice []T, where func(t T) bool) bool
- func CheckChanged[T interface{}](source []T, target []T, where func(t1 T, t2 T) bool) ([]T, []T, []T)
- func ChooseTrueValue[T interface{}](condition bool, trueValue, falseValue T) T
- func Contains[T interface{}](slice []T, comparable func(t T) bool) bool
- func ContainsByValue[T comparable](slice []T, e T) bool
- func Distinct[T comparable](slice []T) []T
- func FindList[T interface{}](slice []T, comparable func(t T) bool) []T
- func FindOne[T interface{}](slice []T, comparable func(t T) bool) T
- func FirstOrDefault[T interface{}](slice []T) T
- func Float32ValuePoint(value float32) *float32
- func Float64ValuePoint(value float64) *float64
- func GetAuthorizationToken(ctx context.Context) string
- func GetDistance(lon1, lat1, lon2, lat2 float64) float64
- func GetMultiDistance(lon1 float64, lat1 float64, points []*Point) map[int]float64
- func GetPath[T interface{}]() string
- func GetPathByValue(table interface{}) string
- func GetValueByFieldName(o interface{}, name string) any
- func GetValueFromContext(ctx context.Context, key string) string
- func GroupBy[T interface{}, TResult comparable](slice []T, selector func(t T) TResult) map[TResult][]T
- func Int32Value(str *wrapperspb.Int32Value) int32
- func Int32ValuePoint(value int32) *int32
- func Int64ValuePoint(value int64) *int64
- func IntValuePoint(value int) *int
- func Intersect[T comparable](a []T, b []T) []T
- func IsInherit[TSource any, Target any]() bool
- func IsNotNullOrEmpty(str *wrapperspb.StringValue) bool
- func IsNullOrEmpty(str *wrapperspb.StringValue) bool
- func IsNullOrEmptyString(str string) bool
- func IsPointer(param interface{}) bool
- func IsPointerReturnValue(param interface{}) (interface{}, bool)
- func IsType[TSource any, Target any]() (*TSource, *Target, bool)
- func IsTypeByValue[T any](value any) (*T, bool)
- func LocalPager[T interface{}](source []T, page int32, pageSize int32) []T
- func MaxOne[T interface{}, TResult interface{ ... }](slice []T, comparable func(t T) TResult) T
- func MaxValue[T interface{}, TResult interface{ ... }](slice []T, comparable func(t T) TResult) TResult
- func MinOne[T interface{}, TResult interface{ ... }](slice []T, comparable func(t T) TResult) T
- func MinValue[T interface{}, TResult interface{ ... }](slice []T, comparable func(t T) TResult) TResult
- func NumberValuePoint[T interface{ ... }](value T) *T
- func OrderByNumber[T interface{}, TResult interface{ ... }](slice []T, asc bool, order func(t T) TResult) []T
- func OrderByString[T interface{}](slice []T, asc bool, order func(t T) string) []T
- func Remove[T interface{}](source []*T, where func(item *T) bool) []*T
- func Select[T interface{}, TResult interface{}](slice []T, selectFunc func(t T) TResult) []TResult
- func SelectMany[T interface{}, TResult interface{}](slice []T, selectFunc func(t T) []TResult) []TResult
- func SelectString[T interface{}](slice []T, selectFunc func(t T) string) []string
- func StringValue(str *wrapperspb.StringValue) string
- func StringValuePoint(value string) *string
- func StringWrapper(str string) *wrapperspb.StringValue
- func Sum[T interface{}, TTarget interface{ ... }](slice []T, selectFunc func(t T) TTarget) TTarget
- func ValidatePassword(password string, min int, max int) bool
- type Point
Constants ¶
View Source
const (
EARTH_RADIUS = 6371393 // 地球半径,单位:米
)
Variables ¶
View Source
var Time timeExt
Functions ¶
func CheckChanged ¶
func CheckChanged[T interface{}](source []T, target []T, where func(t1 T, t2 T) bool) ([]T, []T, []T)
CheckChanged 比较两个集合,返回 新增、修改、删除 的数据
func ChooseTrueValue ¶
func ChooseTrueValue[T interface{}](condition bool, trueValue, falseValue T) T
ChooseTrueValue 模拟三元表达式,获取值
func ContainsByValue ¶
func ContainsByValue[T comparable](slice []T, e T) bool
ContainsByValue 判断数组是否包含某个项
func FindList ¶
func FindList[T interface{}](slice []T, comparable func(t T) bool) []T
FindList 从数组中返回所有符合条件的项
func FindOne ¶
func FindOne[T interface{}](slice []T, comparable func(t T) bool) T
FindOne 从数组中返回第一个符合条件的项
func FirstOrDefault ¶
func FirstOrDefault[T interface{}](slice []T) T
func Float32ValuePoint ¶
func Float64ValuePoint ¶
func GetAuthorizationToken ¶
func GetDistance ¶
GetDistance 计算两个经纬度距离,单位米
func GetMultiDistance ¶
GetMultiDistance 计算多个经纬度 与 给定坐标的距离,单位米
func GetValueByFieldName ¶
GetValueByFieldName 获取指定字段的值
func GroupBy ¶
func GroupBy[T interface{}, TResult comparable](slice []T, selector func(t T) TResult) map[TResult][]T
GroupBy 分组
func Int32ValuePoint ¶
func Int64ValuePoint ¶
func IntValuePoint ¶
func IsNotNullOrEmpty ¶
func IsNotNullOrEmpty(str *wrapperspb.StringValue) bool
IsNotNullOrEmpty 判断字符串非空
func IsPointerReturnValue ¶
func IsPointerReturnValue(param interface{}) (interface{}, bool)
IsPointerReturnValue 判断是否是指针,并返回真实值
func IsTypeByValue ¶
IsTypeByValue 判断 value 是否等于或者实现 T
func LocalPager ¶
LocalPager 本地分页
func MaxOne ¶
func MaxOne[T interface{}, TResult interface { int | int32 | int64 | float32 | float64 }](slice []T, comparable func(t T) TResult) T
MaxOne 从数组中返回最大值的项
func MaxValue ¶
func MaxValue[T interface{}, TResult interface { int | int32 | int64 | float32 | float64 }](slice []T, comparable func(t T) TResult) TResult
MaxValue 从数组中返回最大值
func MinOne ¶
func MinOne[T interface{}, TResult interface { int | int32 | int64 | float32 | float64 }](slice []T, comparable func(t T) TResult) T
MinOne 从数组中返回最小值的项
func MinValue ¶
func MinValue[T interface{}, TResult interface { int | int32 | int64 | float32 | float64 }](slice []T, comparable func(t T) TResult) TResult
MinValue 从数组中返回最小值
func NumberValuePoint ¶
func OrderByNumber ¶
func OrderByString ¶
func Remove ¶
func Remove[T interface{}](source []*T, where func(item *T) bool) []*T
Remove 删除集合中指定元素,返回删除后的数据
func Select ¶
func Select[T interface{}, TResult interface{}](slice []T, selectFunc func(t T) TResult) []TResult
Select 选择单项,返回集合
func SelectMany ¶
func SelectMany[T interface{}, TResult interface{}](slice []T, selectFunc func(t T) []TResult) []TResult
SelectMany 选择集合,返回合并后的集合
func SelectString ¶
SelectString 选择字符串,返回集合
func StringValuePoint ¶
func StringWrapper ¶
func StringWrapper(str string) *wrapperspb.StringValue
StringWrapper 字符串包装为可空类型
Types ¶
Click to show internal directories.
Click to hide internal directories.