Documentation ¶
Overview ¶
Package util implements other tool more, like type cover, type value check.
Index ¶
- Constants
- func DecT36(num int) string
- func DecT62(num int) string
- func ExtractArrUnique[T constraints.ValueIterable](count int, arr []T) []T
- func ExtractParam[T constraints.Equable](defValue T, args ...T) T
- func InQue(val any, que []any) int
- func InQueAny(que any, keys ...any) int
- func ListIndex[T constraints.Equable](list []T, value T) (index int)
- func MapAssign[K constraints.KeyIterable, V constraints.ValueIterable](source map[K]V, more ...map[K]V) map[K]V
- func MapFilter[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
- func MapGenByKv[K constraints.KeyIterable, V constraints.ValueIterable](keys []K, values []V) (kv map[K]V)
- func MapKeys[T constraints.KeyIterable, X constraints.ValueIterable](vMap map[T]X) (keys []T)
- func MapSlice[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
- func MapToStructViaJson(mapValue any, structPtr any) error
- func MapValues[T constraints.KeyIterable, X constraints.KeyIterable](vMap map[T]X) (values []X)
- func NullDefault(value, def any) any
- func Round(num float64, b int) float64
- func SpendTimeDiff() func() time.Duration
- func StructToMap(value any, ignoreKeys ...string) map[string]any
- func StructToMapLStyle(value any, ignoreKeys ...string) map[string]any
- func StructToMapViaJson(value any, ignoreKeys ...string) map[string]any
- func ToMapLStyleIgnoreEmpty(value any, ignoreKeys ...string) map[string]any
- func TryAssignValue(src reflect.Value, tgt reflect.Value) bool
- func ValueNull(value any) bool
- type Decimal
- type Object
Constants ¶
const ( // NumberStr 9+26+26+3 NumberStr = "0123456789abcdefghijklmnopkrstuvwxyzABCDEFGHIJKLMNOPKRSTUVWXYZ+-=" // N2 进制类型 N2 = 2 N8 = 8 N16 = 16 N32 = 32 N36 = 36 N62 = 62 )
@Date: 2018/12/12 0012 13:45 @Author: Joshua Conero @Name: 10 进制处理
Variables ¶
This section is empty.
Functions ¶
func ExtractArrUnique ¶ added in v1.4.0
func ExtractArrUnique[T constraints.ValueIterable](count int, arr []T) []T
ExtractArrUnique extracting array elements with loss (non-repeatable) from an array
func ExtractParam ¶ added in v1.3.0
func ExtractParam[T constraints.Equable](defValue T, args ...T) T
ExtractParam Extract indefinite parameters from functions and default code values Deprecated: please replace by `rock.ExtractParam`,will remove in future
func ListIndex ¶ added in v1.2.0
func ListIndex[T constraints.Equable](list []T, value T) (index int)
ListIndex get index by search value from list
func MapAssign ¶ added in v1.4.0
func MapAssign[K constraints.KeyIterable, V constraints.ValueIterable](source map[K]V, more ...map[K]V) map[K]V
MapAssign Merge multiple map parameters, where the same key value is the forward overwrite value.
And never return nil.
func MapFilter ¶ added in v1.4.0
func MapFilter[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
MapFilter use the keys of map to filter itself
func MapGenByKv ¶ added in v1.2.0
func MapGenByKv[K constraints.KeyIterable, V constraints.ValueIterable](keys []K, values []V) (kv map[K]V)
MapGenByKv Create dictionary by key value pair array combination
func MapKeys ¶ added in v1.2.0
func MapKeys[T constraints.KeyIterable, X constraints.ValueIterable](vMap map[T]X) (keys []T)
MapKeys Extract the key name array of the dictionary
func MapSlice ¶ added in v1.4.0
func MapSlice[K constraints.KeyIterable, V constraints.ValueIterable](kv map[K]V, filter []K) map[K]V
MapSlice use the keys of map to slice itself
func MapToStructViaJson ¶ added in v1.4.0
MapToStructViaJson use the map value to set structPtr
func MapValues ¶ added in v1.2.0
func MapValues[T constraints.KeyIterable, X constraints.KeyIterable](vMap map[T]X) (values []X)
MapValues Extract the values name array of the dictionary
func NullDefault ¶ added in v1.1.0
NullDefault null value handler to default.
func Round ¶ added in v0.2.0
Round String method processing float equal length data specified digits
func SpendTimeDiff ¶ added in v1.1.0
SpendTimeDiff Get the program spend time for any format.
func StructToMap ¶ added in v1.1.0
StructToMap convert Struct field to by Map, support the Ptr
func StructToMapLStyle ¶ added in v1.1.0
StructToMapLStyle convert Struct field to by Map and key is Lower style, key support `JSON.TAG`. Notice: reflect field num not contain inherit struct.
func StructToMapViaJson ¶ added in v1.1.0
StructToMapViaJson convert map via json Marshal/Unmarshal StructToMapViaJson is slower than StructToMapLStyle by Benchmark
func ToMapLStyleIgnoreEmpty ¶ added in v1.1.0
ToMapLStyleIgnoreEmpty convert Struct field to by Map and key is Lower style and ignore empty. StructToMapViaJson is slower than StructToMapLStyle by Benchmark
func TryAssignValue ¶ added in v1.4.0
TryAssignValue try assign value to another value.
Types ¶
type Object ¶ added in v1.1.0
type Object struct { }
func (Object) Assign ¶ added in v1.1.0
Assign Base of `reflect` to come true like javascript `Object.Assign`, target should be pointer best. It can be Multiple, only for `reflect.Map`. And support nested struct. @todo 将使用 reflect 与 未使用reflect从包去区分开
func (Object) AssignCovert ¶ added in v1.3.0
AssignCovert Simple type automatic coverage, supporting cross type. So do not try to cover complex type. number covert any -> string string -> number
Directories ¶
Path | Synopsis |
---|---|
Package rock As the cornerstone of implementing generic methods, implementing generic related operations with minimal dependencies.
|
Package rock As the cornerstone of implementing generic methods, implementing generic related operations with minimal dependencies. |