ref

package
v1.0.12 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TypeString   = reflect.TypeOf("")
	TypeBool     = reflect.TypeOf(false)
	TypeByte     = reflect.TypeOf(byte(0))
	TypeRune     = reflect.TypeOf(rune(0))
	TypeInt      = reflect.TypeOf(int(0))
	TypeInt32    = reflect.TypeOf(int32(0))
	TypeInt64    = reflect.TypeOf(int64(0))
	TypeFloat32  = reflect.TypeOf(float32(0))
	TypeFloat64  = reflect.TypeOf(float64(0))
	TypeDuration = reflect.TypeOf(time.Duration(0))
	TypeTime     = reflect.TypeOf(time.Time{})
)

Functions

func ArrayGet added in v1.0.10

func ArrayGet(a any, idxs ...int) (any, error)

ArrayGet getting value from array or slice by index usage:

a := [][]string{
    { "0,0", "0,1" },
    { "1,0", "1,1" },
}

{{ArrayGet a 0 1 }} // return "0,1"

func ArrayOf added in v1.0.10

func ArrayOf[T any](args ...T) []T

ArrayOf returns a []T{args[0], args[1], ...}

func ArraySet added in v1.0.10

func ArraySet(a any, i int, v any) (any, error)

ArraySet set value to the array or slice by index

func Convert

func Convert(v any, t reflect.Type) (cv any, err error)

Convert convert the value v to the specified Type t

func IsArrayType added in v1.0.10

func IsArrayType(v any) bool

IsArrayType return true if v is a map

func IsComplexType

func IsComplexType(v any) bool

IsComplexType return true if v is a complex

func IsFloatType

func IsFloatType(v any) bool

IsFloatType return true if v is a float

func IsIntType

func IsIntType(v any) bool

IsIntType return true if v is an integer

func IsMapType added in v1.0.10

func IsMapType(v any) bool

IsMapType return true if v is a map

func MapGet added in v1.0.10

func MapGet(dict any, keys ...any) (any, error)

MapGet getting value from map by keys usage:

m := map[string]any{
    "a": 1,
    "1": map[string]float64{
        "c": 4,
    },
}

{{MapGet m "a" }} // return 1 {{MapGet m 1 "c" }} // return 4

func MapSet added in v1.0.10

func MapSet(dict any, key, val any) (any, error)

MapSet setting value to the map

func SetProperty added in v1.0.10

func SetProperty(o any, k string, v any) (err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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