1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-06 21:52:28 +08:00

doc: update doc for convertor package

This commit is contained in:
dudaodong
2023-01-01 22:00:23 +08:00
parent 9b6a004dbc
commit 6d7dec1cea
4 changed files with 104 additions and 40 deletions

View File

@@ -187,23 +187,55 @@ import "github.com/duke-git/lancet/v2/convertor"
```
#### Function list:
- **<big>ColorHexToRGB</big>** : convert color hex to color rgb.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ColorHexToRGB)]
[[play](https://go.dev/play/p/o7_ft-JCJBV)]
- **<big>ColorRGBToHex</big>** : convert rgb color to hex color.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ColorRGBToHex)]
[[play](https://go.dev/play/p/nzKS2Ro87J1)]
- **<big>ToBool</big>** : convert string to bool.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToBool)]
[[play](https://go.dev/play/p/ARht2WnGdIN)]
- **<big>ToBytes</big>** : convert value to byte slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToBytes)]
[[play](https://go.dev/play/p/fAMXYFDvOvr)]
- **<big>ToChar</big>** : convert string to char slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToChar)]
[[play](https://go.dev/play/p/JJ1SvbFkVdM)]
- **<big>ToChannel</big>** : convert a collection of elements to a read-only channel.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToChannel)]
[[play](https://go.dev/play/p/hOx_oYZbAnL)]
- **<big>ToFloat</big>** : convert value to float64, if param is a invalid floatable, will return 0.0 and error.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToFloat)]
[[play](https://go.dev/play/p/4YTmPCibqHJ)]
- **<big>ToInt</big>** : convert value to int64 value, if input is not numerical, return 0 and error.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToInt)]
[[play](https://go.dev/play/p/9_h9vIt-QZ_b)]
- **<big>ToJson</big>** : convert value to a json string.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToJson)]
[[play](https://go.dev/play/p/2rLIkMmXWvR)]
- **<big>ToMap</big>** : convert a slice of structs to a map based on iteratee function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToMap)]
[[play](https://go.dev/play/p/tVFy7E-t24l)]
- **<big>ToPointer</big>** : return a pointer of passed value.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToPointer)]
[[play](https://go.dev/play/p/ASf_etHNlw1)]
- **<big>ToString</big>** : convert value to string.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToString)]
[[play](https://go.dev/play/p/nF1zOOslpQq)]
- **<big>StructToMap</big>** : convert struct to map, only convert exported struct field.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#StructToMap)]
[[play](https://go.dev/play/p/KYGYJqNUBOI)]
- **<big>MapToSlice</big>** : convert map to slice based on iteratee function.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#MapToSlice)]
[[play](https://go.dev/play/p/dmX4Ix5V6Wl)]
- **<big>EncodeByte</big>** : encode data to byte slice.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#EncodeByte)]
[[play](https://go.dev/play/p/DVmM1G5JfuP)]
- **<big>DecodeByte</big>** : decode byte slice data to target object.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#DecodeByte)]
[[play](https://go.dev/play/p/zI6xsmuQRbn)]
- [ColorHexToRGB](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ColorHexToRGB)
- [ColorRGBToHex](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ColorRGBToHex)
- [ToBool](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToBool)
- [ToBytes](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToBytes)
- [ToChar](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToChar)
- [ToChannel](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToChannel)
- [ToFloat](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToFloat)
- [ToInt](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToInt)
- [ToJson](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToJson)
- [ToMap](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToMap)
- [ToPointer](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToPointer)
- [ToString](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToString)
- [StructToMap](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#StructToMap)
- [MapToSlice](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#MapToSlice)
- [EncodeByte](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#EncodeByte)
- [DecodeByte](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#DecodeByte)
### 5. Cryptor package is for data encryption and decryption.

View File

@@ -185,23 +185,55 @@ import "github.com/duke-git/lancet/v2/convertor"
```
#### 函数列表:
- [ColorHexToRGB](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ColorHexToRGB)
- [ColorRGBToHex](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ColorRGBToHex)
- [ToBool](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToBool)
- [ToBytes](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToBytes)
- [ToChar](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToChar)
- [ToChannel](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToChannel)
- [ToFloat](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToFloat)
- [ToInt](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToInt)
- [ToJson](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToJson)
- [ToMap](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToMap)
- [ToPointer](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToPointer)
- [ToString](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToString)
- [StructToMap](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#StructToMap)
- [MapToSlice](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#MapToSlice)
- [EncodeByte](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#EncodeByte)
- [DecodeByte](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#DecodeByte)
- **<big>ColorHexToRGB</big>** : 颜色值十六进制转rgb。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ColorHexToRGB)]
[[play](https://go.dev/play/p/o7_ft-JCJBV)]
- **<big>ColorRGBToHex</big>** : 颜色值rgb转十六进制。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ColorRGBToHex)]
[[play](https://go.dev/play/p/nzKS2Ro87J1)]
- **<big>ToBool</big>** : 字符串转布尔类型使用strconv.ParseBool。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToBool)]
[[play](https://go.dev/play/p/ARht2WnGdIN)]
- **<big>ToBytes</big>** : interface转字节切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToBytes)]
[[play](https://go.dev/play/p/fAMXYFDvOvr)]
- **<big>ToChar</big>** : 字符串转字符切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToChar)]
[[play](https://go.dev/play/p/JJ1SvbFkVdM)]
- **<big>ToChannel</big>** : 将切片转为只读channel。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToChannel)]
[[play](https://go.dev/play/p/hOx_oYZbAnL)]
- **<big>ToFloat</big>** : 将interface转成float64类型如果参数无法转换会返回0.0和error。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToFloat)]
[[play](https://go.dev/play/p/4YTmPCibqHJ)]
- **<big>ToInt</big>** : 将interface转成int64类型如果参数无法转换会返回0和error。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToInt)]
[[play](https://go.dev/play/p/9_h9vIt-QZ_b)]
- **<big>ToJson</big>** : 将interface转成json字符串如果参数无法转换会返回""和error。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToJson)]
[[play](https://go.dev/play/p/2rLIkMmXWvR)]
- **<big>ToMap</big>** : 将切片转为map。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToMap)]
[[play](https://go.dev/play/p/tVFy7E-t24l)]
- **<big>ToPointer</big>** : 返回传入值的指针。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToPointer)]
[[play](https://go.dev/play/p/ASf_etHNlw1)]
- **<big>ToString</big>** : 将值转换为字符串,对于数字、字符串、[]byte将转换为字符串。 对于其他类型(切片、映射、数组、结构)将调用 json.Marshal。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToString)]
[[play](https://go.dev/play/p/nF1zOOslpQq)]
- **<big>StructToMap</big>** : 将struct转成map只会转换struct中可导出的字段。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#StructToMap)]
[[play](https://go.dev/play/p/KYGYJqNUBOI)]
- **<big>MapToSlice</big>** : map中key和value执行函数iteratee后转为切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#MapToSlice)]
[[play](https://go.dev/play/p/dmX4Ix5V6Wl)]
- **<big>EncodeByte</big>** : 将传入的data编码成字节切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#EncodeByte)]
[[play](https://go.dev/play/p/DVmM1G5JfuP)]
- **<big>DecodeByte</big>** : 解码字节切片到目标对象,目标对象需要传入一个指针实例。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#DecodeByte)]
[[play](https://go.dev/play/p/zI6xsmuQRbn)]
### 5. cryptor 加密包支持数据加密和解密,获取 md5hash 值。支持 base64, md5, hmac, aes, des, rsa。

View File

@@ -102,7 +102,7 @@ func main() {
### <span id="ToBool">ToBool</span>
<p>Convert string to a boolean value. Use strconv.ParseBool</p>
<p>Convert string to bool. Use strconv.ParseBool.</p>
<b>Signature:</b>
@@ -138,7 +138,7 @@ func main() {
### <span id="ToBytes">ToBytes</span>
<p>Convert interface to byte slice.</p>
<p>Convert value to byte slice.</p>
<b>Signature:</b>
@@ -200,7 +200,7 @@ func main() {
### <span id="ToChannel">ToChannel</span>
<p>Convert a collection of elements to a read-only channels.</p>
<p>Convert a collection of elements to a read-only channel.</p>
<b>Signature:</b>
@@ -238,7 +238,7 @@ func main() {
### <span id="ToFloat">ToFloat</span>
<p>Convert interface to a float64 value. If param is a invalid floatable, will return 0 and error. </p>
<p>Convert value to a float64 value. If param is a invalid floatable, will return 0.0 and error. </p>
<b>Signature:</b>
@@ -271,7 +271,7 @@ func main() {
### <span id="ToInt">ToInt</span>
<p>Convert interface to a int64 value. If param is a invalid intable, will return 0 and error. </p>
<p>Convert value to a int64 value. If param is a invalid intable, will return 0 and error. </p>
<b>Signature:</b>
@@ -332,7 +332,7 @@ func main() {
### <span id="ToMap">ToMap</span>
<p>Convert a slice or an array of structs to a map based on iteratee function. </p>
<p>Convert a slice of structs to a map based on iteratee function. </p>
<b>Signature:</b>

View File

@@ -522,7 +522,7 @@ func main() {
### <span id="DecodeByte">DecodeByte</span>
<p>解码字节切片到目标对象,目标对象需要传入一个指针实例</p>
<p>解码字节切片到目标对象,目标对象需要传入一个指针实例</p>
<b>函数签名:</b>