anyx

package
v0.0.0-...-8845ca5 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: AGPL-3.0 Imports: 15 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFound = errors.New("not found")
)

Functions

func DeepCopy

func DeepCopy[M any](src, dst M)

func DeepEqual

func DeepEqual[M any](x, y M) bool

func DiffSlice

func DiffSlice(a interface{}, b interface{}) (interface{}, interface{})

DiffSlice 传入两个slice 如果 a 或者 b 不为 slice 会 panic 如果 a 与 b 的元素类型不一致,也会 panic 返回的第一个参数为 a 比 b 多的,类型为 a 的类型 返回的第二个参数为 b 比 a 多的,类型为 b 的类型

func KeyBy

func KeyBy(list interface{}, fieldName string) interface{}

func KeyByInt64

func KeyByInt64[M any](list []*M, fieldName string) map[int64]*M

func KeyByUint64

func KeyByUint64[M any](list []*M, fieldName string) map[uint64]*M

func MapKeysInt64

func MapKeysInt64(m interface{}) []int64

func MapKeysString

func MapKeysString(m interface{}) []string

func MapKeysUint64

func MapKeysUint64(m interface{}) []uint64

func MapValues

func MapValues(m interface{}) interface{}

func PluckInt

func PluckInt(list interface{}, fieldName string) []int

func PluckInt32

func PluckInt32(list interface{}, fieldName string) []int32

func PluckInt64

func PluckInt64(list interface{}, fieldName string) []int64

func PluckString

func PluckString(list interface{}, fieldName string) []string

func PluckStringSlice

func PluckStringSlice(list interface{}, fieldName string) [][]string

func PluckUint32

func PluckUint32(list interface{}, fileName string) []uint32

func PluckUint64

func PluckUint64(list interface{}, fieldName string) []uint64

func RemoveSlice

func RemoveSlice(src interface{}, rm interface{}) interface{}

RemoveSlice 传入两个slice 如果 src 或者 rm 不为 slice 会 panic 如果 src 与 rm 的元素类型不一致,也会 panic 返回的第一个参数为 src 中不在 rm 中的元素,数据类型与 src 一致

func Slice2Map

func Slice2Map[M constraints.Ordered](list []M) map[M]bool

func ToBool

func ToBool(val interface{}) bool

func ToFloat32

func ToFloat32(val interface{}) float32

func ToFloat64

func ToFloat64(val interface{}) float64

func ToFloat64Slice

func ToFloat64Slice(val interface{}) []float64

func ToInt

func ToInt(val interface{}) int

func ToInt16

func ToInt16(val interface{}) int16

func ToInt32

func ToInt32(val interface{}) int32

func ToInt64

func ToInt64(val interface{}) int64

func ToInt64Slice

func ToInt64Slice(val interface{}) []int64

func ToInt8

func ToInt8(val interface{}) int8

func ToString

func ToString(val interface{}) string

func ToStringSlice

func ToStringSlice(val interface{}, seqs ...string) []string

func ToUint

func ToUint(val interface{}) uint

func ToUint16

func ToUint16(val interface{}) uint16

func ToUint32

func ToUint32(val interface{}) uint32

func ToUint64

func ToUint64(val interface{}) uint64

func ToUint8

func ToUint8(val interface{}) uint8

Types

type Map

type Map struct {
	// contains filtered or unexported fields
}

func NewMap

func NewMap(m map[string]interface{}) *Map

func NewMapWithAny

func NewMapWithAny(s interface{}) (*Map, error)

func NewMapWithJson

func NewMapWithJson(s []byte) (*Map, error)

func NewMapWithYaml

func NewMapWithYaml(s []byte) (*Map, error)

func (*Map) Clone

func (p *Map) Clone() *Map

func (*Map) DisableCut

func (p *Map) DisableCut() *Map

func (*Map) EnableCut

func (p *Map) EnableCut(seq string) *Map

func (*Map) Exists

func (p *Map) Exists(key string) bool

func (*Map) Get

func (p *Map) Get(key string) (interface{}, error)

func (*Map) GetBool

func (p *Map) GetBool(key string) bool

func (*Map) GetBytes

func (p *Map) GetBytes(key string) []byte

func (*Map) GetFloat64

func (p *Map) GetFloat64(key string) float64

func (*Map) GetInt

func (p *Map) GetInt(key string) int

func (*Map) GetInt32

func (p *Map) GetInt32(key string) int32

func (*Map) GetInt64

func (p *Map) GetInt64(key string) int64

func (*Map) GetInt64Slice

func (p *Map) GetInt64Slice(key string) []int64

func (*Map) GetMap

func (p *Map) GetMap(key string) *Map

func (*Map) GetSlice

func (p *Map) GetSlice(key string) []interface{}

func (*Map) GetString

func (p *Map) GetString(key string) string

func (*Map) GetStringSlice

func (p *Map) GetStringSlice(key string) []string

func (*Map) GetUint16

func (p *Map) GetUint16(key string) uint16

func (*Map) GetUint32

func (p *Map) GetUint32(key string) uint32

func (*Map) GetUint32Slice

func (p *Map) GetUint32Slice(key string) []uint32

func (*Map) GetUint64

func (p *Map) GetUint64(key string) uint64

func (*Map) GetUint64Slice

func (p *Map) GetUint64Slice(key string) []uint64

func (*Map) Range

func (p *Map) Range(f func(key, value interface{})) bool

func (*Map) Set

func (p *Map) Set(key string, value interface{})

func (*Map) ToMap

func (p *Map) ToMap() map[string]interface{}

func (*Map) ToSyncMap

func (p *Map) ToSyncMap() *sync.Map

type ValueType

type ValueType int
const (
	ValueUnknown ValueType = iota
	ValueNumber
	ValueString
	ValueBool
)

func CheckValueType

func CheckValueType(val interface{}) ValueType

Jump to

Keyboard shortcuts

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