Documentation ¶
Index ¶
- Variables
- func Add(a, b interface{}) interface{}
- func AndNot(a, b interface{}) interface{}
- func Append(a interface{}, vals ...interface{}) (ret interface{})
- func BitAnd(a, b interface{}) interface{}
- func BitNot(a interface{}) interface{}
- func BitOr(a, b interface{}) interface{}
- func Bool(a interface{}) bool
- func Cap(a interface{}) int
- func CloseChan(v interface{})
- func Copy(dst, src interface{}) int
- func Dec(a interface{}) interface{}
- func Delete(m interface{}, key interface{})
- func EQ(a, b interface{}) interface{}
- func Elem(a interface{}) interface{}
- func Float32(a interface{}) float32
- func Float64(a interface{}) float64
- func GE(a, b interface{}) interface{}
- func GT(a, b interface{}) interface{}
- func Get(m interface{}, key interface{}, defaultValues ...interface{}) (result interface{})
- func GetVar(m interface{}, key interface{}) interface{}
- func In(a, b interface{}) interface{}
- func Inc(a interface{}) interface{}
- func Int(a interface{}) int
- func Int16(a interface{}) int16
- func Int32(a interface{}) int32
- func Int64(a interface{}) int64
- func Int8(a interface{}) int8
- func LE(a, b interface{}) interface{}
- func LT(a, b interface{}) interface{}
- func Len(a interface{}) int
- func Lshr(a, b interface{}) interface{}
- func Make(typ yaksepc.GoTyper, args ...int) interface{}
- func Map(key, elem interface{}) interface{}
- func MapFrom(args ...interface{}) interface{}
- func MapInit(args ...interface{}) interface{}
- func MapOf(key, val interface{}) interface{}
- func Max(args ...interface{}) (max interface{})
- func Min(args ...interface{}) (min interface{})
- func Mkmap(typ interface{}, n ...int) interface{}
- func Mkslice(typ interface{}, args ...interface{}) interface{}
- func Mod(a, b interface{}) interface{}
- func Mul(a, b interface{}) interface{}
- func NE(a, b interface{}) interface{}
- func Neg(a interface{}) interface{}
- func Not(a interface{}) interface{}
- func Panic(v interface{})
- func Panicf(format string, args ...interface{})
- func Quo(a, b interface{}) interface{}
- func Rshr(a, b interface{}) interface{}
- func Set(m interface{}, args ...interface{})
- func SetIndex(m, key, v interface{})
- func Slice(elem interface{}) interface{}
- func SliceFrom(args ...interface{}) interface{}
- func SliceFromTy(args ...interface{}) interface{}
- func SliceOf(typ interface{}) interface{}
- func String(a interface{}) string
- func StringEx(a interface{}, verbose string) string
- func StructInit(args ...interface{}) interface{}
- func Sub(a, b interface{}) interface{}
- func SubSlice(a, i, j interface{}) interface{}
- func Ternary(condation, a, b interface{}) interface{}
- func Uint(a interface{}) uint
- func Uint16(a interface{}) uint16
- func Uint32(a interface{}) uint32
- func Uint64(a interface{}) uint64
- func Uint8(a interface{}) byte
- func Xor(a, b interface{}) interface{}
Constants ¶
This section is empty.
Variables ¶
var TyBool = tyBool(0)
TyBool represents the `bool` type.
var TyByte = TyUint8
TyByte represents the `byte` type.
var TyFloat = TyFloat64
TyFloat represents the `float` type.
var TyFloat32 = tyFloat32(0)
TyFloat32 represents the `float32` type.
var TyFloat64 = tyFloat64(0)
TyFloat64 represents the `float64` type.
var TyInt = tyInt(0)
TyInt represents the `int` type.
var TyInt16 = tyInt16(0)
TyInt16 represents the `int16` type.
var TyInt32 = tyInt32(0)
TyInt32 represents the `int32` type.
var TyInt64 = tyInt64(0)
TyInt64 represents the `int64` type.
var TyInt8 = tyInt8(0)
TyInt8 represents the `int8` type.
var TyString = tyString(0)
TyString represents the `string` type.
var TyUint = tyUint(0)
TyUint represents the `uint` type.
var TyUint16 = tyUint16(0)
TyUint16 represents the `uint16` type.
var TyUint32 = tyUint32(0)
TyUint32 represents the `uint32` type.
var TyUint64 = tyUint64(0)
TyUint64 represents the `uint64` type.
var TyUint8 = tyUint8(0)
TyUint8 represents the `uint8` type.
var TyVar = tyVar(0)
TyVar represents the `var` type.
var YaklangBaseLib = map[string]interface{}{ "retry": utils.Retry2, "append": Append, "copy": Copy, "delete": Delete, "get": Get, "len": Len, "cap": Cap, "mkmap": Mkmap, "mapFrom": MapFrom, "mapOf": MapOf, "mkslice": Mkslice, "slice": Mkslice, "sliceFrom": SliceFrom, "sliceOf": SliceOf, "sub": SubSlice, "panic": Panic, "panicf": Panicf, "print": print, "printf": printf, "println": println, "sprint": sprint, "sprintf": sprintf, "sprintln": sprintln, "fprint": fprint, "fprintf": fprintf, "fprintln": fprintln, "set": Set, "make": Make, "close": CloseChan, "float": TyFloat64, "float64": TyFloat64, "float32": TyFloat32, "int8": TyInt8, "int16": TyInt16, "int32": TyInt32, "int64": TyInt64, "int": TyInt, "uint": TyUint, "byte": TyUint8, "uint8": TyUint8, "uint16": TyUint16, "uint32": TyUint32, "uint64": TyUint64, "string": TyString, "bool": TyBool, "var": TyVar, "max": Max, "min": Min, "undefined": yaklangspec.Undefined, "nil": nil, "true": true, "false": false, "$elem": Elem, "$neg": Neg, "$mul": Mul, "$quo": Quo, "$mod": Mod, "$add": Add, "$sub": Sub, "$ternary": Ternary, "$in": In, "$xor": Xor, "$lshr": Lshr, "$rshr": Rshr, "$bitand": BitAnd, "$bitor": BitOr, "$bitnot": BitNot, "$andnot": AndNot, "$lt": LT, "$gt": GT, "$le": LE, "$ge": GE, "$eq": EQ, "$ne": NE, "$not": Not, }
Functions ¶
func Append ¶
func Append(a interface{}, vals ...interface{}) (ret interface{})
append 将元素追加到数组或切片中,并将结果返回 Example: ``` a = [1, 2, 3] a = append(a, 4, 5, 6) println(a) // [1 2 3 4 5 6] ```
func Cap ¶
func Cap(a interface{}) int
cap 返回集合对象的容量,对象可以是数组(array),切片(slice)或通道(channel) Example: ``` a = make([]int, 0, 3) println(cap(a)) // 3 ```
func CloseChan ¶
func CloseChan(v interface{})
close 用于关闭已经打开的通道(channel),关闭一个已经关闭的通道会导致运行时崩溃 Example: ``` ch = make(chan int) go func() { for i = range ch { println(i) } }() ch <- 1 ch <- 2 close(ch) ```
func Copy ¶
func Copy(dst, src interface{}) int
copy 将 src 数组/切片复制到 dst 数组/切片中,并返回复制的元素个数 Example: ``` a = [1, 2, 3] b = make([]int, 3) copy(b, a) println(b) // [1 2 3] ```
func Delete ¶
func Delete(m interface{}, key interface{})
delete 从map中删除key Example: ``` m = {"a": 1, "b": 2} delete(m, "b") println(m) // {"a": 1} ```
func Get ¶
func Get(m interface{}, key interface{}, defaultValues ...interface{}) (result interface{})
get 从map中获取键值,如果键不存在,则返回默认值 Example: ``` m = {"a": 1, "b": 2} get(m, "a") // 1 get(m, "c", "default") // "default" ```
func GetVar ¶
func GetVar(m interface{}, key interface{}) interface{}
GetVar returns a member variable of an object. object can be a slice, an array, a map or a user-defined class.
func Len ¶
func Len(a interface{}) int
len 返回集合对象的长度,对象可以是数组(array),切片(slice),映射(map),字符串(string)或通道(channel) Example: ``` a = [1, 2, 3] println(len(a)) // 3 ```
func MapFrom ¶
func MapFrom(args ...interface{}) interface{}
mapFrom 根据传入的键值对初始化映射(map) ! 已弃用,可以使用 map 初始化语句代替 Example: ``` m = mapFrom("a", 1, "b", 2) // {"a": 1, "b": 2} ```
func MapInit ¶
func MapInit(args ...interface{}) interface{}
MapInit creates a map object from `mapInit(mapType, member1, val1, ...)`.
func MapOf ¶
func MapOf(key, val interface{}) interface{}
mapOf 返回指定类型的映射类型,可用于 mkmap 中 ! 已弃用,可以使用 make 语句代替 Example: ``` m = mkmap(mapOf("string", "var")) // map[string]any ```
func Max ¶
func Max(args ...interface{}) (max interface{})
max 返回多个值中的最大值,这只对数字类型有效 Example: ``` max(1,2,3,4,5) // 5 max(1,1.1,2.2,3.3,4.4,5.5) // 5.5 ```
func Min ¶
func Min(args ...interface{}) (min interface{})
min 返回多个值中的最小值,这只对数字类型有效 Example: ``` min(1,2,3,4,5) // 1 min(1,1.1,2.2,3.3,4.4,5.5) // 1 ```
func Mkmap ¶
func Mkmap(typ interface{}, n ...int) interface{}
mkmap 创建指定类型的映射(map) ! 已弃用,可以使用 make 语句代替 Example: ``` m = mkmap("string:var") // map[string]any ```
func Mkslice ¶
func Mkslice(typ interface{}, args ...interface{}) interface{}
mkslice 创建指定类型的切片(slice) ! 已弃用,可以使用 make 语句代替 Example: ``` a = mkslice("var") // []any ```
func Panicf ¶
func Panicf(format string, args ...interface{})
panicf 崩溃并根据格式化打印错误信息 Example: ``` panicf("something happened: %v", err) ```
func Set ¶
func Set(m interface{}, args ...interface{})
set 设置一个对象的值,对象可以是数组(array),切片(slice),映射(map)或结构体(struct)或结构体引用(ptr) ! 已弃用,可以使用初始化语句或赋值语句代替 Example: ``` a = make([]int, 3) set(a, 0, 100, 1, 200, 2, 300) // a = [100, 200, 300] ```
func SetIndex ¶
func SetIndex(m, key, v interface{})
SetIndex sets a (index, value) pair to an object. object can be a slice, an array, a map or a user-defined class.
func SliceFrom ¶
func SliceFrom(args ...interface{}) interface{}
sliceFrom 根据传入的键值对初始化切片(slice) ! 已弃用,可以使用 slice 初始化语句代替 Example: ``` a = sliceFrom(1, 2, 3) // [1, 2, 3] ```
func SliceFromTy ¶
func SliceFromTy(args ...interface{}) interface{}
SliceFromTy creates a slice from `[]T{a1, a2, ...}`.
func SliceOf ¶
func SliceOf(typ interface{}) interface{}
sliceOf 返回指定类型的切片类型,可用于 mkslice 中 ! 已弃用,可以使用 make 语句代替 Example: ``` m = mkslice(sliceOf("var")) // []any ```
func StructInit ¶
func StructInit(args ...interface{}) interface{}
StructInit creates a struct object from `structInit(structType, member1, val1, ...)`.
Types ¶
This section is empty.