mapx

package
v0.0.0-...-4da1013 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 6 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewMap = map[string]func(args ...interface{}) interface{}{}

Functions

func Array

func Array(t map[string]interface{}, key string) (r []interface{})

获取map的array, 如果不存在就创建一个

func ArrayByMap

func ArrayByMap(val interface{}, handler func(length int, keys []int, items []interface{})) (r []interface{})

func Bool

func Bool(t map[string]interface{}, key string) (r bool)

func BoolDefault

func BoolDefault(t map[string]interface{}, key string, dflt bool) (r bool)

func CloneAny

func CloneAny(a interface{}) (r interface{})

func CloneArray

func CloneArray(a []interface{}) (r []interface{})

func CloneMap

func CloneMap(a map[string]interface{}) (r map[string]interface{})

func Copy

func Copy(from, to map[string]interface{})

func CopyNoCover

func CopyNoCover(from, to map[string]interface{})

func CreateByPath

func CreateByPath(path string) map[string]interface{}

func CreateConfigMap2

func CreateConfigMap2(keys []string, r map[string]interface{}, val interface{})

func CreateConfigMap3

func CreateConfigMap3(keys string, r map[string]interface{}, val interface{})

func DeleteByKeyMap

func DeleteByKeyMap(a, keyMap map[string]interface{}, isDeleteKeyMap bool) (deleteMap map[string]interface{})

根据提供的keyMap,删除a的键值 只要存在对应的键,不管是什么值都删除 isDeleteKeyMap 会同时删除keyMap中的键

func DeleteByPath

func DeleteByPath(t map[string]interface{}, path string)

path = "/a/b/c"

func ExportField

func ExportField(source, fieldMap datax.M) (r datax.M)

输出指定字段

func FilterMap

func FilterMap(a map[string]interface{}, f func(parent map[string]interface{}, key string, val interface{}) bool) map[string]interface{}

f 返回true表示需要过滤掉

func FilterMapNotDefault

func FilterMapNotDefault(a map[string]interface{}) map[string]interface{}

过滤掉default值的字段

func FilterMapNotNil

func FilterMapNotNil(a map[string]interface{}) map[string]interface{}

过滤掉nil值的字段

func Flat

func Flat(t map[string]interface{}, detail bool) map[string]interface{}

func Float64

func Float64(t map[string]interface{}, key string) (r float64)

func Float64Default

func Float64Default(t map[string]interface{}, key string, dflt float64) (r float64)

func GetByPath

func GetByPath(t map[string]interface{}, path string) (value interface{}, has bool)

path = "/a/b/c"

func Has

func Has(t map[string]interface{}, key string) bool

func HasByPath

func HasByPath(t map[string]interface{}, path string) bool

目标map是否有路径

func HasKeys

func HasKeys(t map[string]interface{}, keys ...string) bool

func Int

func Int(t map[string]interface{}, key string) (r int)

func IntDefault

func IntDefault(t map[string]interface{}, key string, dflt int) (r int)

func Interface

func Interface(t map[string]interface{}, key string) (r interface{})

func Keys

func Keys(t map[string]interface{}) (r []string)

func Map

func Map(t map[string]interface{}, key string) (r map[string]interface{})

func MapByPath

func MapByPath(t map[string]interface{}, path string, autoCreate bool) (r map[string]interface{})

如果map路径不存在, 会创建map path = "/a/b/c/.." 如果path = "/" 直接返回t

func Set

func Set(t map[string]interface{}, key string, val interface{})

func SetByPath

func SetByPath(t map[string]interface{}, path string, value interface{})

path = "/a/b/c"

func String

func String(t map[string]interface{}, key string) (r string)

func StringDefault

func StringDefault(t map[string]interface{}, key string, dflt string) (r string)

func StructFromByInterface

func StructFromByInterface(target, val interface{}, args ...interface{}) (r interface{})

func StructFromByType

func StructFromByType(val interface{}, args ...interface{}) (r interface{})

func StructToByType

func StructToByType(val interface{}, args ...interface{}) (r interface{})

func StructToValue

func StructToValue(st IToMap, val interface{}, name string, args ...interface{})

func StructToValueNotNull

func StructToValueNotNull(st IToMap, args ...interface{}) (r interface{})

func ToMapAllStruct

func ToMapAllStruct(st IToMapAll, val interface{}, args ...interface{})

func ToMapInterface

func ToMapInterface(st interface{}, val interface{}, args ...interface{}) (r interface{})

func ToMapStruct

func ToMapStruct(st IToMap, val interface{}, args ...interface{})

func ToMapStructByType

func ToMapStructByType(val interface{}, args ...interface{}) (r interface{})

func WalkMap

func WalkMap(a map[string]interface{}, f func(parent map[string]interface{}, key string, val interface{}) error) error

Types

type IFromMap

type IFromMap interface {
	FromMap(m map[string]interface{}, args ...interface{})
}

func StructFromValue

func StructFromValue(st IFromMap, val interface{}, args ...interface{}) IFromMap

type IStructName

type IStructName interface {
	StructName() string
}

type IToMap

type IToMap interface {
	ToMap(m map[string]interface{}, args ...interface{})
}

type IToMapAll

type IToMapAll interface {
	ToMapAll(m map[string]interface{}, args ...interface{})
}

Jump to

Keyboard shortcuts

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