From 844b7a2c3b44c72a443946d0338a03839f8ba7f0 Mon Sep 17 00:00:00 2001 From: dudaodong Date: Tue, 20 Jun 2023 10:59:12 +0800 Subject: [PATCH] release v2.2.2 --- README.md | 20 +++++++++++++++++--- README_zh-CN.md | 25 ++++++++++++++++++------- docs/convertor_zh-CN.md | 8 +++++--- 3 files changed, 40 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index a4f8cc9..a910c8e 100644 --- a/README.md +++ b/README.md @@ -282,6 +282,10 @@ import "github.com/duke-git/lancet/v2/convertor" - **ToInterface** : converts reflect value to its interface type. [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#ToInterface)] [[play](https://go.dev/play/p/syqw0-WG7Xd)] +- **Utf8ToGbk** : converts utf8 encoding data to GBK encoding data + [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#Utf8ToGbk)] +- **GbkToUtf8** : converts GBK encoding data to utf8 encoding data. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor.md#GbkToUtf8)] ### 6. Cryptor package is for data encryption and decryption. @@ -581,9 +585,11 @@ import "github.com/duke-git/lancet/v2/fileutil" - **ReadFileByLine** : read file line by line, return string slice of file content. [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#ReadFileByLine)] [[play](https://go.dev/play/p/svJP_7ZrBrD)] -- **Zip** : create zip file. +- **Zip** : create a zip file of fpath, fpath could be a file or a directory. [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#Zip)] [[play](https://go.dev/play/p/j-3sWBp8ik_P)] +- **ZipAppendEntry** : append a single file or directory by fpath to an existing zip file. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#ZipAppendEntry)] - **UnZip** : unzip the zip file and save it to dest path. [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#UnZip)] [[play](https://go.dev/play/p/g0w34kS7B8m)] @@ -605,6 +611,8 @@ import "github.com/duke-git/lancet/v2/fileutil" - **ReadCsvFile** : read file content into slice. [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#ReadCsvFile)] [[play](https://go.dev/play/p/OExTkhGEd3_u)] +- **WriteCsvFile** : write content to target csv file. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#WriteCsvFile)] - **WriteBytesToFile** : write bytes to target file. [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#WriteBytesToFile)] [[play](https://go.dev/play/p/s7QlDxMj3P8)] @@ -825,7 +833,10 @@ import "github.com/duke-git/lancet/v2/mathutil" - **Sin** : return the sine of the radian argument. [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#Sin)] [[play](https://go.dev/play/p/TWMQlMywDsP)] - +- **Log** : returns the logarithm of base n. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#Log)] +- **Sum** : return sum of passed numbers. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#Sum)] ### 14. Netutil package contains functions to get net information and send http request. @@ -932,6 +943,8 @@ import "github.com/duke-git/lancet/v2/random" - **UUIdV4** : generate a random UUID of version 4 according to RFC 4122. [[doc](https://github.com/duke-git/lancet/blob/main/docs/random.md#UUIdV4)] [[play](https://go.dev/play/p/_Z9SFmr28ft)] +- **RandUniqueIntSlice** : generate a slice of random int of length n that do not repeat. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/random.md#RandUniqueIntSlice)] ### 16. Retry package is for executing a function repeatedly until it was successful or canceled by the context. @@ -1405,7 +1418,8 @@ import "github.com/duke-git/lancet/v2/strutil" - **HideString** : Hide some chars in source string with param `replaceChar`. [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#HideString)] [[play](https://go.dev/play/p/pzbaIVCTreZ)] - +- **RemoveWhiteSpace** : remove whitespace characters from a string. + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#RemoveWhiteSpace)] ### 21. System package contain some functions about os, runtime, shell command. diff --git a/README_zh-CN.md b/README_zh-CN.md index 1c94471..4a2dc31 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -25,7 +25,7 @@ - 👏 全面、高效、可复用。 - 💪 500+常用 go 工具函数,支持 string、slice、datetime、net、crypt... - 💅 只依赖 go 标准库和 golang.org/x。 -- 🌍 所有导出函数单元测试覆盖率100%。 +- 🌍 所有导出函数单元测试覆盖率 100%。 ## 安装 @@ -281,6 +281,10 @@ import "github.com/duke-git/lancet/v2/convertor" - **ToInterface** : 将反射值转换成对应的 interface 类型。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#ToInterface)] [[play](https://go.dev/play/p/syqw0-WG7Xd)] +- **Utf8ToGbk** : utf8 编码转 GBK 编码。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#Utf8ToGbk)] +- **GbkToUtf8** : GBK 编码转 utf8 编码。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/convertor_zh-CN.md#GbkToUtf8)] ### 6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。 @@ -503,7 +507,6 @@ import "github.com/duke-git/lancet/v2/datetime" [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#IsWeekend)] [[play](https://go.dev/play/p/cupRM5aZOIY)] - ### 8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph. ```go @@ -586,6 +589,8 @@ import "github.com/duke-git/lancet/v2/fileutil" - **Zip** : zip 压缩文件, 参数可以是文件或目录。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#Zip)] [[play](https://go.dev/play/p/j-3sWBp8ik_P)] +- **ZipAppendEntry** : 通过将单个文件或目录追加到现有的 zip 文件。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#ZipAppendEntry)] - **UnZip** : zip 解压缩文件并保存在目录中。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#UnZip)] [[play](https://go.dev/play/p/g0w34kS7B8m)] @@ -607,14 +612,14 @@ import "github.com/duke-git/lancet/v2/fileutil" - **ReadCsvFile** : 读取 csv 文件内容到切片。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#ReadCsvFile)] [[play](https://go.dev/play/p/OExTkhGEd3_u)] -- **WriteBytesToFile** : 将bytes写入文件。 +- **WriteCsvFile** : 向 csv 文件写入内容。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#WriteCsvFile)] +- **WriteBytesToFile** : 将 bytes 写入文件。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#WriteBytesToFile)] [[play](https://go.dev/play/p/s7QlDxMj3P8)] - **WriteStringToFile** : 将字符串写入文件。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#WriteStringToFile)] [[play](https://go.dev/play/p/GhLS6d8lH_g)] - - ### 10. formatter 格式化器包含一些数据格式化处理方法。 @@ -828,7 +833,10 @@ import "github.com/duke-git/lancet/v2/mathutil" - **Sin** : 计算弧度的正弦值。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#Sin)] [[play](https://go.dev/play/p/TWMQlMywDsP)] - +- **Log** : 计算以 base 为底 n 的对数。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#Log)] +- **Sum** : 求传入参数之和。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#Sum)] ### 14. netutil 网络包支持获取 ip 地址,发送 http 请求。 @@ -935,6 +943,8 @@ import "github.com/duke-git/lancet/v2/random" - **UUIdV4** : 生成 UUID v4 字符串。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/random_zh-CN.md#UUIdV4)] [[play](https://go.dev/play/p/_Z9SFmr28ft)] +- **RandUniqueIntSlice** : 生成一个不重复的长度为n的随机int切片。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/random_zh-CN.md#RandUniqueIntSlice)] ### 16. retry 重试执行函数直到函数运行成功或被 context cancel。 @@ -1411,7 +1421,8 @@ import "github.com/duke-git/lancet/v2/strutil" - **HideString** : 隐藏源字符串中的一些字符。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#HideString)] [[play](https://go.dev/play/p/pzbaIVCTreZ)] - +- **RemoveWhiteSpace** : 删除字符串中的空格。 + [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#RemoveWhiteSpace)] ### 21. system 包含 os, runtime, shell command 的相关函数。 diff --git a/docs/convertor_zh-CN.md b/docs/convertor_zh-CN.md index 9fe35d7..0a51f48 100644 --- a/docs/convertor_zh-CN.md +++ b/docs/convertor_zh-CN.md @@ -41,6 +41,8 @@ import ( - [DeepClone](#DeepClone) - [CopyProperties](#CopyProperties) - [ToInterface](#ToInterface) +- [Utf8ToGbk](#Utf8ToGbk) +- [GbkToUtf8](#GbkToUtf8)
@@ -838,7 +840,7 @@ func main() { // Output: // true - // true + // true } ``` @@ -871,6 +873,6 @@ func main() { // Output: // true - // hello + // hello } -``` \ No newline at end of file +```