ztype

package
v1.7.17 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: MIT Imports: 13 Imported by: 29

Documentation

Overview

Package ztype provides Variable Type Related Operations

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnyToDecimal added in v1.1.11

func AnyToDecimal(value string, base int) (v int)

AnyToDecimal Convert arbitrary decimal values to decimal

func DecimalToAny added in v1.1.11

func DecimalToAny(value, base int) (newNumStr string)

DecimalToAny Convert decimal to arbitrary decimal values

func GetType

func GetType(s interface{}) string

GetType Get variable type

func InArray added in v0.0.19

func InArray(needle, hystack interface{}) bool

func IsBool

func IsBool(v interface{}) bool

IsBool Is Bool

func IsByte

func IsByte(v interface{}) bool

IsByte Is []byte

func IsEmpty added in v0.0.19

func IsEmpty(value interface{}) bool

func IsFloat32

func IsFloat32(v interface{}) bool

IsFloat32 Is float32

func IsFloat64

func IsFloat64(v interface{}) bool

IsFloat64 Is float64

func IsInt

func IsInt(v interface{}) bool

IsInt Is int

func IsInt16

func IsInt16(v interface{}) bool

IsInt16 Is int16

func IsInt32

func IsInt32(v interface{}) bool

IsInt32 Is int32

func IsInt64

func IsInt64(v interface{}) bool

IsInt64 Is int64

func IsInt8

func IsInt8(v interface{}) bool

IsInt8 Is int8

func IsInterface

func IsInterface(v interface{}) bool

IsInterface Is interface{}

func IsString

func IsString(v interface{}) bool

IsString Is String

func IsStruct

func IsStruct(v interface{}) bool

IsStruct Is Struct

func IsUint

func IsUint(v interface{}) bool

IsUint Is uint

func IsUint16

func IsUint16(v interface{}) bool

IsUint16 Is uint16

func IsUint32

func IsUint32(v interface{}) bool

IsUint32 Is uint32

func IsUint64

func IsUint64(v interface{}) bool

IsUint64 Is uint64

func IsUint8

func IsUint8(v interface{}) bool

IsUint8 Is uint8

func MapKeyExists

func MapKeyExists(key interface{}, m map[interface{}]interface{}) bool

MapKeyExists Whether the dictionary key exists

func SliceStrToAny added in v1.6.4

func SliceStrToAny(slice []string) []interface{}

SliceStrToAny []string to []interface{}

func To added in v1.6.4

func To(input, out interface{}, opt ...func(*Conver)) error

func ToBool

func ToBool(i interface{}) bool

ToBool To Bool

func ToBytes added in v1.4.3

func ToBytes(i interface{}) []byte

ToByte To []byte

func ToFloat32

func ToFloat32(i interface{}) float32

ToFloat32 To float32

func ToFloat64

func ToFloat64(i interface{}) float64

ToFloat64 To float64

func ToInt

func ToInt(i interface{}) int

ToInt To int

func ToInt16

func ToInt16(i interface{}) int16

ToInt16 To int16

func ToInt32

func ToInt32(i interface{}) int32

ToInt32 To int32

func ToInt64

func ToInt64(i interface{}) int64

ToInt64 To int64

func ToInt8

func ToInt8(i interface{}) int8

ToInt8 To int8

func ToString

func ToString(i interface{}) string

ToString To String

func ToStruct added in v1.6.4

func ToStruct(v interface{}, outVal interface{}) error

ToStruct map or struct to struct

func ToTime added in v1.3.8

func ToTime(i interface{}, format ...string) (time.Time, error)

ToTime To time.Time

func ToUint

func ToUint(i interface{}) uint

ToUint To uint

func ToUint16

func ToUint16(i interface{}) uint16

ToUint16 To uint16

func ToUint32

func ToUint32(i interface{}) uint32

ToUint32 To uint32

func ToUint64

func ToUint64(i interface{}) uint64

ToUint64 To uint64

func ToUint8

func ToUint8(i interface{}) uint8

ToUint8 To uint8

func ValueConv added in v1.6.6

func ValueConv(input interface{}, out reflect.Value, opt ...func(*Conver)) error

Types

type Conver added in v1.6.4

type Conver struct {
	MatchName     func(mapKey, fieldName string) bool
	ConvHook      func(name string, i reflect.Value, o reflect.Type) (reflect.Value, bool)
	TagName       string
	IgnoreTagName bool
	ZeroFields    bool
	Squash        bool
	Deep          bool
	Merge         bool
}

type Map added in v1.3.7

type Map map[string]interface{}

func ToMap added in v1.4.3

func ToMap(value interface{}) Map

func (Map) DeepCopy added in v1.5.2

func (m Map) DeepCopy() Map

func (Map) Delete added in v1.4.3

func (m Map) Delete(key string) error

func (Map) ForEach added in v1.6.0

func (m Map) ForEach(fn func(k string, v Type) bool)

func (Map) Get added in v1.3.7

func (m Map) Get(key string, disabled ...bool) Type

func (Map) Has added in v1.5.2

func (m Map) Has(key string) bool

func (Map) IsEmpty added in v1.4.2

func (m Map) IsEmpty() bool

func (Map) Set added in v1.4.2

func (m Map) Set(key string, value interface{}) error

type Maps added in v1.3.6

type Maps []Map

func ToMaps added in v1.6.4

func ToMaps(value interface{}) Maps

ToMaps to Slice Map

func (Maps) First added in v1.7.0

func (m Maps) First() Map

func (Maps) ForEach added in v1.4.4

func (m Maps) ForEach(fn func(i int, value Map) bool)

func (Maps) Index added in v1.4.2

func (m Maps) Index(i int) Map

func (Maps) IsEmpty added in v1.4.2

func (m Maps) IsEmpty() bool

func (Maps) Last added in v1.7.0

func (m Maps) Last() Map

func (Maps) Len added in v1.4.2

func (m Maps) Len() int

type SliceType added in v1.4.3

type SliceType []Type

func Slice deprecated added in v0.0.19

func Slice(value interface{}, noConv ...bool) SliceType

Deprecated: please use ToSlice

func ToSlice added in v1.3.6

func ToSlice(value interface{}, noConv ...bool) (s SliceType)

func (SliceType) First added in v1.7.0

func (s SliceType) First() Type

func (SliceType) Index added in v1.4.3

func (s SliceType) Index(i int) Type

func (SliceType) Int added in v1.4.5

func (s SliceType) Int() []int

func (SliceType) Last added in v1.7.0

func (s SliceType) Last() Type

func (SliceType) Len added in v1.4.4

func (s SliceType) Len() int

func (SliceType) Maps added in v1.5.2

func (s SliceType) Maps() Maps

func (SliceType) MarshalJSON added in v1.6.4

func (s SliceType) MarshalJSON() ([]byte, error)

func (SliceType) String added in v1.4.5

func (s SliceType) String() []string

func (SliceType) Value added in v1.4.3

func (s SliceType) Value() []interface{}

type StruBuilder added in v1.3.3

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

func NewMapStruct added in v1.3.1

func NewMapStruct(key interface{}) *StruBuilder

func NewSliceStruct added in v1.3.3

func NewSliceStruct() *StruBuilder

func NewStruct added in v1.3.1

func NewStruct() *StruBuilder

func NewStructFromValue added in v1.7.15

func NewStructFromValue(v interface{}) (*StruBuilder, error)

func (*StruBuilder) AddField added in v1.3.3

func (b *StruBuilder) AddField(name string, fieldType interface{}, tag ...string) *StruBuilder

func (*StruBuilder) Copy added in v1.3.3

func (b *StruBuilder) Copy(v *StruBuilder) *StruBuilder

func (*StruBuilder) FieldNames added in v1.7.15

func (b *StruBuilder) FieldNames() []string

全部字段名

func (*StruBuilder) GetField added in v1.3.3

func (b *StruBuilder) GetField(name string) *StruField

func (*StruBuilder) HasField added in v1.3.3

func (b *StruBuilder) HasField(name string) bool

func (*StruBuilder) Interface added in v1.3.3

func (b *StruBuilder) Interface() interface{}

func (*StruBuilder) Merge added in v1.3.3

func (b *StruBuilder) Merge(values ...interface{}) error

func (*StruBuilder) RemoveField added in v1.3.3

func (b *StruBuilder) RemoveField(name string) *StruBuilder

func (*StruBuilder) String added in v1.7.15

func (b *StruBuilder) String() string

func (*StruBuilder) Type added in v1.3.3

func (b *StruBuilder) Type() reflect.Type

func (*StruBuilder) Value added in v1.3.3

func (b *StruBuilder) Value() reflect.Value

type StruField added in v1.3.3

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

func (*StruField) SetTag added in v1.3.3

func (f *StruField) SetTag(tag string) *StruField

func (*StruField) SetType added in v1.3.3

func (f *StruField) SetType(typ interface{}) *StruField

type Type added in v1.3.6

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

func New added in v1.3.6

func New(v interface{}) Type

func (Type) Bool added in v1.3.6

func (t Type) Bool(def ...bool) bool

func (Type) Bytes added in v1.4.3

func (t Type) Bytes(def ...[]byte) []byte

func (Type) Exists added in v1.3.6

func (t Type) Exists() bool

func (Type) Float32 added in v1.3.6

func (t Type) Float32(def ...float32) float32

func (Type) Float64 added in v1.3.6

func (t Type) Float64(def ...float64) float64

func (Type) Get added in v1.4.2

func (t Type) Get(path string) Type

func (Type) Int added in v1.3.6

func (t Type) Int(def ...int) int

func (Type) Int16 added in v1.3.6

func (t Type) Int16(def ...int16) int16

func (Type) Int32 added in v1.3.6

func (t Type) Int32(def ...int32) int32

func (Type) Int64 added in v1.3.6

func (t Type) Int64(def ...int64) int64

func (Type) Int8 added in v1.3.6

func (t Type) Int8(def ...int8) int8

func (Type) Map added in v1.4.3

func (t Type) Map() Map

func (Type) Maps added in v1.6.4

func (t Type) Maps() Maps

func (Type) Slice added in v1.3.6

func (t Type) Slice(noConv ...bool) SliceType

func (Type) SliceInt added in v1.6.3

func (t Type) SliceInt(noConv ...bool) []int

func (Type) SliceString added in v1.6.3

func (t Type) SliceString(noConv ...bool) []string

func (Type) SliceValue added in v1.4.3

func (t Type) SliceValue(noConv ...bool) []interface{}

func (Type) String added in v1.3.6

func (t Type) String(def ...string) string

func (Type) Time added in v1.3.8

func (t Type) Time(format ...string) (time.Time, error)

func (Type) Uint added in v1.3.6

func (t Type) Uint(def ...uint) uint

func (Type) Uint16 added in v1.3.6

func (t Type) Uint16(def ...uint16) uint16

func (Type) Uint32 added in v1.3.6

func (t Type) Uint32(def ...uint32) uint32

func (Type) Uint64 added in v1.3.6

func (t Type) Uint64(def ...uint64) uint64

func (Type) Uint8 added in v1.3.6

func (t Type) Uint8(def ...uint8) uint8

func (Type) Value added in v1.3.6

func (t Type) Value() interface{}

Jump to

Keyboard shortcuts

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