fn

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptIgnore    = "-"         // 忽略当前这个域
	OptOmitempty = "omitempty" // 当这个域的值为空,忽略这个域
	OptDive      = "dive"      // 递归地遍历这个结构体,将所有字段作为键
	OptWildcard  = "wildcard"  // 只适用于字符串类型,返回"%"+值+"%",这是为了方便数据库的模糊查询
)

Variables

This section is empty.

Functions

func Apply

func Apply(obj_func interface{}, args []interface{}) []reflect.Value

Apply 通过反射支持字符串直接调用函数

func Assign

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

Assign

func AssignMap

func AssignMap(m1 ts.Map, m2 ts.Map) ts.Map

合并两个map

func Bytes2String

func Bytes2String(b []byte) string

Bytes2String 高性能转换

func Call

func Call(obj_func interface{}, args ...interface{}) []reflect.Value

Call 通过反射支持字符串直接调用函数

func CallMethod

func CallMethod(obj interface{}, methodName string, args ...interface{}) []reflect.Value

CallMethod @param obj 为结构体指针

func FmtString

func FmtString(src string, data map[string]interface{}) string

FmtString @param str @param data @example FmtString("{a}",map[string]interfacle{}{"a":1})

func GetKind

func GetKind(v interface{}) reflect.Kind

GetKind 通过反射获取数据类型 GetKind(string) == "string" GetKind(nil)

func GetReflectType

func GetReflectType(v interface{}) reflect.Type

GetType 获取类型

func GetStructTypeName

func GetStructTypeName(v interface{}) string

获取一个struct的类型名称

func GoFns

func GoFns(num int, fns []func()) (wg *sync.WaitGroup)

GoFns

func GoFnsGroupBy

func GoFnsGroupBy(count int, num int, fns []func()) *sync.WaitGroup

GoFnsGroupBy

func Has

func Has(obj interface{}, key string) bool

Has 通过判断对象是否包含某一个类型

func IsBlank

func IsBlank(str string) bool

IsBlank check the string is blank string

func IsEmail

func IsEmail(value string) bool

IsEmail 判断字符串是否符合邮箱地址

func IsNumeric

func IsNumeric(str string) bool

IsNumeric 判断字符串是否是数字

func IsPtr

func IsPtr(v interface{}) bool

IsPtr 是否为指针

func IsString

func IsString(v interface{}) bool

IsString

func IsURL

func IsURL(str string) bool

判断字符串是否是一个url地址

func Load

func Load(url string) ([]byte, error)

Load 下载

func LoadAndSave

func LoadAndSave(url string, filePath string) error

LoadAndSave 下载保存

func MapToStruct

func MapToStruct(m map[string]interface{}, s interface{}) error

ToStruct 用map填充结构

func New

func New(v interface{}) interface{}

New 通过反射创建结构体对象,这里最好只传递引用类型

func NewSlice

func NewSlice(v interface{}) interface{}

NewSlice 通过反射创建结构体对象

func ParseBool

func ParseBool(str string) (bool, error)

Bool 将字符串转换为布尔值 它接受真值:1, t, T, TRUE, true, True 它接受假值:0, f, F, FALSE, false, False. 其它任何值都返回一个错误

func ParseFloat32

func ParseFloat32(str string) (float32, error)

ParseFloat32

func ParseFloat64

func ParseFloat64(str string) (float64, error)

ParseFloat64

func ParseHex

func ParseHex(str string) (uint64, error)

ParseHex

func ParseInt

func ParseInt(str string) (int, error)

ParseInt

func ParseInt16

func ParseInt16(str string) (int16, error)

ParseInt16

func ParseInt32

func ParseInt32(str string) (int32, error)

ParseInt32

func ParseInt64

func ParseInt64(str string) (int64, error)

ParseInt64

func ParseInt8

func ParseInt8(str string) (int8, error)

ParseInt8

func ParseUint

func ParseUint(str string) (uint, error)

ParseUint

func ParseUint64

func ParseUint64(str string) (uint64, error)

ParseUint64

func ReverseString

func ReverseString(s string) string

ReverseString 反转字符串

func ReverseStringOffset

func ReverseStringOffset(s string, offset rune) string

ReverseStringOffset

func String2Bytes

func String2Bytes(s string) []byte

String2Bytes 高性能转换

func StructToMap

func StructToMap(s interface{}, tag string, methodName string) (res map[string]interface{}, err error)

StructToMap 结构体转map fn.StructToMap(struct, "map", "")

func ToCamelCase

func ToCamelCase(val string) string

ToCamelCase

func ToSliceReflectValue

func ToSliceReflectValue(args []interface{}) []reflect.Value

ToSliceReflectValue

Types

This section is empty.

Jump to

Keyboard shortcuts

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