refx

package
v1.2.7 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: GPL-3.0 Imports: 9 Imported by: 2

Documentation

Overview

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/20 11:26
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/20 11:22
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/20 11:21
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/20 11:21
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/20 11:24
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/20 11:23
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/21 19:53
  • @version 1.0

*

  • @copyright 像衍科技-idr.ai
  • @author 牛牛-研发部-www.ruomm.com
  • @create 2024/1/19 21:02
  • @version 1.0

*

  • @copyright www.ruomm.com
  • @author 牛牛-wanruome@126.com
  • @create 2024/3/28 12:58
  • @version 1.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseStringToSlice

func ParseStringToSlice(key string, viString string, splitTag string, destSliceKind reflect.Kind, destTypeName string) (interface{}, error)

func ParseToBool

func ParseToBool(origVal interface{}, cpOpt string) interface{}

转换各种类型为bool类型,整形进行转换,字符串进行格式转换

func ParseToFloat64

func ParseToFloat64(origVal interface{}, cpOpt string) interface{}

转换各种类型为浮点型,整形进行转换,字符串进行格式化,时间类型取得毫秒时间戳

func ParseToInt64

func ParseToInt64(origVal interface{}, cpOpt string) (interface{}, string)

转换各种类型为int64,浮点型进行math.Round,字符串进行格式化,时间类型取得毫秒时间戳

func ParseToString

func ParseToString(origVal interface{}, cpOpt string) interface{}

转换各种类型为字符串

func ParseToTime

func ParseToTime(origVal interface{}, cpOpt string) interface{}

转换各种类型为时间类型

func XRefHandlerCopy

func XRefHandlerCopy(xrefOrigHandler XrefHander, destO interface{}, options ...XrefOption) (error, []string)

* origMap:源map数据 destO:目标切片,不可以传入结构体

TransferObj 将origO对象的属性值转成destO对象的属性值,属性对应关系和控制指令通过`xref`标签指定 无标签的如果再按属性名匹配

func XRefMapCopy

func XRefMapCopy(origMap map[string]string, destO interface{}, options ...XrefOption) (error, []string)

* origMap:源map数据 destO:目标切片,不可以传入结构体

TransferObj 将origO对象的属性值转成destO对象的属性值,属性对应关系和控制指令通过`xref`标签指定 无标签的如果再按属性名匹配

func XRefStructCopy

func XRefStructCopy(origO interface{}, destO interface{}, options ...XrefOption) (error, []string)

* origO:源结构体 destO:目标切片,不可以传入结构体

TransferObj 将origO对象的属性值转成destO对象的属性值,属性对应关系和控制指令通过`xref`标签指定 无标签的如果再按属性名匹配

func XRefValueCopy added in v0.3.6

func XRefValueCopy(origO interface{}, refValue reflect.Value, options ...XrefOption) (error, []string)

* origO:源结构体 refValue:目标数据

TransferObj 将origO对象的属性值转成destO对象的属性值,属性对应关系和控制指令通过`xref`标签指定 无标签的如果再按属性名匹配

func XSliceCopy added in v0.3.8

func XSliceCopy(srcSlice interface{}, destSlice interface{}, options ...XrefOption) error

泛型函数,转换一个类型的Slice到另一个类型的Slice,使用xref库进行转换。

func XSliceCopyByKey added in v0.3.8

func XSliceCopyByKey(srcSlice interface{}, destSlice interface{}, key string, options ...XrefOption) error

泛型函数,转换一个类型的Slice到另一个类型的Slice,使用xref库进行转换。

func XSliceCopyToMap added in v0.7.1

func XSliceCopyToMap(srcSlice interface{}, destMap interface{}, keyTag string, valueTag string, options ...XrefOption) error

泛型函数,转换一个类型的Slice到另一个类型的Map,使用xref库进行转换。

func XSliceCopyToMapCommon added in v1.2.0

func XSliceCopyToMapCommon(srcSlice interface{}, destMap interface{}, keyTag string, valueTag string, sameTypeQuote bool, options ...XrefOption) error

泛型函数,转换一个类型的Slice到另一个类型的Map,使用xref库进行转换。quoteSameType:slice和map相同类型时候是否直接应用而不是使用refx复制。

func XStringToSlice added in v0.9.7

func XStringToSlice(str string, sep string, emptyRetain bool, destSlice interface{}, options ...XrefOption) error

泛型函数,转换字符串为特定类型的Slice

func XrefTagTidy

func XrefTagTidy(tagValue string) bool

是否tidy

Types

type XrefHander

type XrefHander func(origKey string, key string, cpOpt string) (interface{}, error)

key目标字段的key值,origKey源字段的key值 返回需要往目标里面注入的值和时候有错误发生

type XrefOption

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

属性空值设置 for refx.

func XrefOptCheckUnsigned added in v0.2.7

func XrefOptCheckUnsigned(checkUnsigned bool) XrefOption

设置无符号字符串是否严格匹配校验

func XrefOptCopyDefault added in v1.1.9

func XrefOptCopyDefault(copyDefault bool) XrefOption

设置没有注解时候是否默认复制

func XrefOptCopyList added in v1.1.9

func XrefOptCopyList(copyList []string) XrefOption

设置没有注解时候复制的来源目标List数据

func XrefOptCopyMap added in v1.1.9

func XrefOptCopyMap(copyMap map[string]string) XrefOption

设置没有注解时候复制的来源目标Map数据

func XrefOptCopyOption added in v0.8.5

func XrefOptCopyOption(copyOption string) XrefOption

设置复制时候的控制属性

func XrefOptMapKeyAppend added in v0.8.5

func XrefOptMapKeyAppend(mapKeyAppend string) XrefOption

设置Map赋值时候的拼接Key值

func XrefOptNameSpace

func XrefOptNameSpace(nameSpace string) XrefOption

设置关联源的nameSpace,不设置则取源对象的类型名称

func XrefOptTag

func XrefOptTag(tag string) XrefOption

设置关联tag的名称,不设置默认为xref

Jump to

Keyboard shortcuts

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