xutil

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2019 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Assert

func Assert(express interface{}, v interface{}, msg ...string)

条件中断,如果express != v 时中断

func Compare

func Compare(v1 interface{}, v2 interface{}, comparer ...CompareFunc) int

比较大小

func Each

func Each(items interface{}, fn EachFunc)

func EachMap

func EachMap(items map[string]interface{}, fn EachFunc)

func EachSlice

func EachSlice(items []interface{}, fn EachFunc)

func EachStruct

func EachStruct(items *struct{}, fn EachFunc)

func Equired

func Equired(v1 interface{}, v2 interface{}, comparer ...CompareFunc) bool

比较是否相等

func Find

func Find(items []interface{}, fn FilterFunc) interface{}

func FindIndex

func FindIndex(items []interface{}, fn FilterFunc) int

func FindTagValue

func FindTagValue(tag reflect.StructTag, field string) interface{}

查找值StructTag中的键值

func If

func If(express bool, trueValue, falseValue interface{}) interface{}

func If_bool

func If_bool(express bool, trueValue, falseValue bool) bool

func If_byte

func If_byte(express bool, trueValue, falseValue byte) byte

func If_float

func If_float(express bool, trueValue, falseValue float32) float32

func If_float64

func If_float64(express bool, trueValue, falseValue float64) float64

func If_int

func If_int(express bool, trueValue, falseValue int) int

func If_int8

func If_int8(express bool, trueValue, falseValue int8) int8

func If_int16

func If_int16(express bool, trueValue, falseValue int8) int8

func If_int32

func If_int32(express bool, trueValue, falseValue int32) int32

func If_int64

func If_int64(express bool, trueValue, falseValue int64) int64

func If_method

func If_method(express bool, trueMethod, falseMethod func())

func If_str

func If_str(express bool, trueValue, falseValue string) string

func If_uint

func If_uint(express bool, trueValue, falseValue uint) uint

func If_uint8

func If_uint8(express bool, trueValue, falseValue uint8) uint8

func If_uint16

func If_uint16(express bool, trueValue, falseValue uint16) uint16

func If_uint32

func If_uint32(express bool, trueValue, falseValue uint32) uint32

func If_uint64

func If_uint64(express bool, trueValue, falseValue uint64) uint64

func Map

func Map(items interface{}, fn MapFunc) interface{}

func MapMap

func MapMap(items map[string]interface{}, fn MapFunc) map[string]interface{}

func MapSlice

func MapSlice(items []interface{}, fn MapFunc) []interface{}

func MapStruct

func MapStruct(items *struct{}, fn MapFunc) map[string]interface{}

func Max

func Max(value1, value2 interface{}) interface{}

获取两项中的大值

func MaxEx

func MaxEx(values ...interface{}) interface{}

获取多项同的大值

func Min

func Min(value1, value2 interface{}) interface{}

获取两项中的小值

func MinEx

func MinEx(values ...interface{}) interface{}

获取多值中的小值

func ParseTag

func ParseTag(tag reflect.StructTag) map[string]interface{}

解析struct tag 允许是json字符串,逗号分割,空格分割

func Thown

func Thown(msg string, code int)

抛出错误

func TryCatch

func TryCatch(try func(), catch func(err XError, args ...interface{}))

try ... catch

func TryFinally

func TryFinally(try func(), finally func(...interface{}))

try finally

Types

type A

type A = []O

type AM

type AM = []M

type CompareFunc

type CompareFunc func(value1, value2 interface{}) int

比较函数

type EachFunc

type EachFunc func(item interface{}, indexOrKey interface{}) interface{}

type FilterFunc

type FilterFunc func(item interface{}, indexOrKey interface{}) bool

type M

type M = map[string]O

type MapFunc

type MapFunc func(item interface{}, indexOrKey interface{}, args ...interface{}) interface{}

type O

type O = interface{}

func If_func

func If_func(express bool, trueFunc, falseFunc func() O) O

type XError

type XError interface {
	GetCode() int
	GetMessage() string
	Error() error
}

func NewError

func NewError(msg string, code int) XError

创建错误类

Jump to

Keyboard shortcuts

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