diff --git a/README.md b/README.md index 95f28bc..1ef5020 100644 --- a/README.md +++ b/README.md @@ -333,7 +333,7 @@ import "github.com/duke-git/lancet/v2/convertor" [[play](https://go.dev/play/p/HwdDPFcza1O)] - **ToBigInt** : converts an integer of any supported type (int, int64, uint64, etc.) to *big.Int. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/convertor.md#ToBigInt)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/X3itkCxwB_x)]

6. Cryptor package is for data encryption and decryption.       index

@@ -469,10 +469,10 @@ import "github.com/duke-git/lancet/v2/cryptor" [[play](https://go.dev/play/p/zutRHrDqs0X)] - **RsaEncrypt** : encrypt data with ras algorithm. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaEncrypt)] - [[play](https://go.dev/play/p/uef0q1fz53I)] + [[play](https://go.dev/play/p/7_zo6mrx-eX)] - **RsaDecrypt** : decrypt data with ras algorithm. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaDecrypt)] - [[play](https://go.dev/play/p/uef0q1fz53I)] + [[play](https://go.dev/play/p/7_zo6mrx-eX)] - **GenerateRsaKeyPair** : creates rsa private and public key. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#GenerateRsaKeyPair)] [[play](https://go.dev/play/p/sSVmkfENKMz)] @@ -484,10 +484,10 @@ import "github.com/duke-git/lancet/v2/cryptor" [[play](https://go.dev/play/p/sSVmkfENKMz)] - **RsaSign** : signs the data with RSA. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaSign)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/qhsbf8BJ6Mf)] - **RsaVerifySign** : verifies the signature of the data with RSA. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/cryptor.md#RsaVerifySign)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/qhsbf8BJ6Mf)]

7. Datetime package supports date and time format and compare.        index

@@ -633,13 +633,13 @@ import "github.com/duke-git/lancet/v2/datetime" [[play](https://go.dev/play/p/6kHBpAxD9ZC)] - **Min** : returns the earliest time among the given times. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#Min)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/MCIDvHNOGGb)] - **Max** : returns the latest time among the given times. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#Max)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/9m6JMk1LB7-)] - **MaxMin** : returns the latest and earliest time among the given times. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/datetime.md#MaxMin)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/rbW51cDtM_2)]

8. Datastructure package contains some common data structure. eg. list, linklist, stack, queue, set, tree, graph.        index

@@ -777,7 +777,7 @@ import "github.com/duke-git/lancet/v2/fileutil" [[play](https://go.dev/play/p/teMXnCsdSEw)] - **GetExeOrDllVersion** : Get the version of exe or dll file on windows os. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/fileutil.md#GetExeOrDllVersion)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/iLRrDBhE38E)]

10. Formatter contains some functions for data formatting.        index

@@ -1145,16 +1145,16 @@ import "github.com/duke-git/lancet/v2/mathutil" [[play](https://go.dev/play/p/WLxDdGXXYat)] - **Variance** : returns the variance of numbers. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Variance)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/uHuV4YgXf8F)] - **StdDev** : returns the standard deviation of numbers. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#StdDev)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/FkNZDXvHD2l)] - **Permutation** : calculates P(n, k). [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Permutation)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/MgobwH_FOxj)] - **Combination** : calculates C(n, k). [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/mathutil.md#Combination)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/ENFQRDQUFi9)]

14. Netutil package contains functions to get net information and send http request.        index

@@ -1317,7 +1317,7 @@ import "github.com/duke-git/lancet/v2/random" [[play](https://go.dev/play/p/68UikN9d6VT)] - **RandNumberOfLength** : generates a random int number of specified length. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandNumberOfLength)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/oyZbuV7bu7b)]

17. Retry package is for executing a function repeatedly until it was successful or canceled by the context.        index

@@ -1613,10 +1613,10 @@ import "github.com/duke-git/lancet/v2/slice" [[play](https://go.dev/play/p/CW3UVNdUZOq)] - **JoinFunc** : joins the slice elements into a single string with the given separator. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#JoinFunc)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/55ib3SB5fM2)] - **ConcatBy** : concats the elements of a slice into a single value using the provided separator and connector function. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#ConcatBy)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/6QcUpcY4UMW)]

19. Stream package implements a sequence of elements supporting sequential and operations. this package is an experiment to explore if stream in go can work as the way java does. its function is very limited.        index

@@ -1709,10 +1709,10 @@ import "github.com/duke-git/lancet/v2/stream" [[play](https://go.dev/play/p/jI6_iZZuVFE)] - **IndexOf** : returns the index of the first occurrence of the specified element in this stream. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#IndexOf)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/tBV5Nc-XDX2)] - **LastIndexOf** : returns the index of the last occurrence of the specified element in this stream. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/stream.md#LastIndexOf)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/CjeoNw2eac_G)]

20. Structs package provides several high level functions to manipulate struct, tag, and field.        index

@@ -1896,7 +1896,7 @@ import "github.com/duke-git/lancet/v2/strutil" [[play](https://go.dev/play/p/JZiu0RXpgN-)] - **ExtractContent** : extracts the content between the start and end strings in the source string. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/strutil.md#ExtractContent)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/Ay9UIk7Rum9)]

22. System package contain some functions about os, runtime, shell command.        index

@@ -2249,7 +2249,7 @@ import "github.com/duke-git/lancet/v2/xerror" [[play](https://go.dev/play/p/acyZVkNZEeW)] - **TryCatch** : simple simulation of Java-style try-catch. [[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/xerror.md#TryCatch)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/D5Mdb0mRj0P)] ## How to Contribute diff --git a/README_zh-CN.md b/README_zh-CN.md index a416fe3..abd42d0 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -333,7 +333,7 @@ import "github.com/duke-git/lancet/v2/convertor" [[play](https://go.dev/play/p/HwdDPFcza1O)] - **ToBigInt** : 将整数转为*big.Int。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/convertor.md#ToBigInt)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/X3itkCxwB_x)]

6. cryptor 加密包支持数据加密和解密,获取 md5,hash 值。支持 base64, md5, hmac, aes, des, rsa。       回到目录

@@ -470,10 +470,10 @@ import "github.com/duke-git/lancet/v2/cryptor" [[play](https://go.dev/play/p/zutRHrDqs0X)] - **RsaEncrypt** : 用公钥文件 ras 加密数据。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaEncrypt)] - [[play](https://go.dev/play/p/uef0q1fz53I)] + [[play](https://go.dev/play/p/7_zo6mrx-eX)] - **RsaDecrypt** : 用私钥文件 rsa 解密数据。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaDecrypt)] - [[play](https://go.dev/play/p/uef0q1fz53I)] + [[play](https://go.dev/play/p/7_zo6mrx-eX)] - **GenerateRsaKeyPair** : 创建rsa公钥私钥和key。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#GenerateRsaKeyPair)] [[play](https://go.dev/play/p/sSVmkfENKMz)] @@ -485,10 +485,10 @@ import "github.com/duke-git/lancet/v2/cryptor" [[play](https://go.dev/play/p/sSVmkfENKMz)] - **RsaSign** : 应用RSA算法签名数据。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaSign)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/qhsbf8BJ6Mf)] - **RsaVerifySign** : 验证数据的签名是否符合RSA算法。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/cryptor.md#RsaVerifySign)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/qhsbf8BJ6Mf)]

7. datetime日期时间处理包,格式化日期,比较日期。       回到目录

@@ -635,13 +635,13 @@ import "github.com/duke-git/lancet/v2/datetime" [[play](https://go.dev/play/p/6kHBpAxD9ZC)] - **Min** : 返回最早时间。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#Min)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/MCIDvHNOGGb)] - **Max** : 返回最晚时间。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#Max)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/9m6JMk1LB7-)] - **MaxMin** : 返回最早和最晚时间。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/datetime.md#MaxMin)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/rbW51cDtM_2)]

8. datastructure 包含一些普通的数据结构实现。例如:list, linklist, stack, queue, set, tree, graph。       回到目录

@@ -776,7 +776,7 @@ import "github.com/duke-git/lancet/v2/fileutil" [[play](https://go.dev/play/p/teMXnCsdSEw)] - **GetExeOrDllVersion** : 返回exe,dll文件版本号(仅Window平台)。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/fileutil.md#GetExeOrDllVersion)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/iLRrDBhE38E)]

10. formatter 格式化器包含一些数据格式化处理方法。       回到目录

@@ -1145,16 +1145,16 @@ import "github.com/duke-git/lancet/v2/mathutil" [[play](https://go.dev/play/p/WLxDdGXXYat)] - **Variance** : 计算方差。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Variance)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/uHuV4YgXf8F)] - **StdDev** : 计算标准差。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#StdDev)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/FkNZDXvHD2l)] - **Permutation** : 计算排列数P(n, k)。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Permutation)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/MgobwH_FOxj)] - **Combination** : 计算组合数C(n, k)。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/mathutil.md#Combination)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/ENFQRDQUFi9)]

14. netutil 网络包支持获取 ip 地址,发送 http 请求。       回到目录

@@ -1317,7 +1317,7 @@ import "github.com/duke-git/lancet/v2/random" [[play](https://go.dev/play/p/68UikN9d6VT)] - **RandNumberOfLength** : 生成指定长度的随机数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandNumberOfLength)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/oyZbuV7bu7b)]

17. retry 重试执行函数直到函数运行成功或被 context cancel。       回到目录

@@ -1610,10 +1610,10 @@ import "github.com/duke-git/lancet/v2/slice" [[play](https://go.dev/play/p/CW3UVNdUZOq)] - **JoinFunc** : 将切片元素用给定的分隔符连接成一个单一的字符串。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#JoinFunc)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/55ib3SB5fM2)] - **ConcatBy** : 将切片中的元素连接成一个值,使用指定的分隔符和连接器函数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#ConcatBy)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/6QcUpcY4UMW)]

19. stream 流,该包仅验证简单的 stream 实现,功能有限。       回到目录

@@ -1706,10 +1706,10 @@ import "github.com/duke-git/lancet/v2/stream" [[play](https://go.dev/play/p/jI6_iZZuVFE)] - **IndexOf** : 返回在stream中找到值的第一个匹配项的索引,如果找不到值,则返回-1。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#IndexOf)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/tBV5Nc-XDX2)] - **LastIndexOf** : 返回在stream中找到值的最后一个匹配项的索引,如果找不到值,则返回-1。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/stream.md#LastIndexOf)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/CjeoNw2eac_G)]

20. structs 提供操作 struct, tag, field 的相关函数。       回到目录

@@ -1896,7 +1896,7 @@ import "github.com/duke-git/lancet/v2/strutil" [[play](https://go.dev/play/p/JZiu0RXpgN-)] - **ExtractContent** : 提取两个标记之间的内容。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/strutil.md#ExtractContent)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/Ay9UIk7Rum9)]

22. system 包含 os, runtime, shell command 的相关函数。       回到目录

@@ -2249,7 +2249,7 @@ import "github.com/duke-git/lancet/v2/xerror" [[play](https://go.dev/play/p/acyZVkNZEeW)] - **TryCatch** : 简单实现的java风格异常处理(try-catch-finally)。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/xerror.md#TryCatch)] - [[play](https://go.dev/play/p/todo)] + [[play](https://go.dev/play/p/D5Mdb0mRj0P)] ## 如何贡献代码 diff --git a/convertor/convertor.go b/convertor/convertor.go index 880fb84..c3f36a5 100644 --- a/convertor/convertor.go +++ b/convertor/convertor.go @@ -143,12 +143,8 @@ func ToString(value any) string { if err != nil { return "" } - return string(b) - // todo: maybe we should't supprt other type conversion - // v := reflect.ValueOf(value) - // log.Panicf("Unsupported data type: %s ", v.String()) - // return "" + return string(b) } } @@ -486,7 +482,7 @@ func ToRawUrlBase64(value any) string { } // ToBigInt converts an integer of any supported type (int, int64, uint64, etc.) to *big.Int -// Play: todo +// Play: https://go.dev/play/p/X3itkCxwB_x func ToBigInt[T any](v T) (*big.Int, error) { result := new(big.Int) diff --git a/cryptor/crypto.go b/cryptor/crypto.go index 11527f2..9f4f338 100644 --- a/cryptor/crypto.go +++ b/cryptor/crypto.go @@ -565,7 +565,7 @@ func GenerateRsaKey(keySize int, priKeyFile, pubKeyFile string) error { } // RsaEncrypt encrypt data with ras algorithm. -// Play: https://go.dev/play/p/rDqTT01SPkZ +// Play: https://go.dev/play/p/7_zo6mrx-eX func RsaEncrypt(data []byte, pubKeyFileName string) []byte { file, err := os.Open(pubKeyFileName) if err != nil { @@ -600,7 +600,7 @@ func RsaEncrypt(data []byte, pubKeyFileName string) []byte { } // RsaDecrypt decrypt data with ras algorithm. -// Play: https://go.dev/play/p/rDqTT01SPkZ +// Play: https://go.dev/play/p/7_zo6mrx-eX func RsaDecrypt(data []byte, privateKeyFileName string) []byte { file, err := os.Open(privateKeyFileName) if err != nil { @@ -663,7 +663,7 @@ func RsaDecryptOAEP(ciphertext []byte, label []byte, key rsa.PrivateKey) ([]byte } // RsaSign signs the data with RSA. -// Play: todo +// Play: https://go.dev/play/p/qhsbf8BJ6Mf func RsaSign(hash crypto.Hash, data []byte, privateKeyFileName string) ([]byte, error) { privateKey, err := loadRasPrivateKey(privateKeyFileName) if err != nil { @@ -679,7 +679,7 @@ func RsaSign(hash crypto.Hash, data []byte, privateKeyFileName string) ([]byte, } // RsaVerifySign verifies the signature of the data with RSA. -// Play: todo +// Play: https://go.dev/play/p/qhsbf8BJ6Mf func RsaVerifySign(hash crypto.Hash, data, signature []byte, pubKeyFileName string) error { publicKey, err := loadRsaPublicKey(pubKeyFileName) if err != nil { @@ -712,7 +712,6 @@ func loadRsaPublicKey(filename string) (*rsa.PublicKey, error) { if blockType == "RSA PUBLIC KEY" { pubKey, err = x509.ParsePKCS1PublicKey(block.Bytes) if err != nil { - // todo: here should be a bug, should return nil, err key, err := x509.ParsePKIXPublicKey(block.Bytes) if err != nil { return nil, err diff --git a/cryptor/rsa_private_example.pem b/cryptor/rsa_private_example.pem index c9d8340..e8ef71c 100644 --- a/cryptor/rsa_private_example.pem +++ b/cryptor/rsa_private_example.pem @@ -1,51 +1,51 @@ -----BEGIN rsa private key----- -MIIJJwIBAAKCAgEAwGdN8KE2NTK41cVN7i6mZZS5J86gjNs0LJDHylb2GG+K4O8s -fq98EMKMJ2xGnKoVRJXucVohr5Eiuf5zgxQe9mpYDyDQ0vnpBkoNkfzJNZQvcQFa -IllUeH+eN4hSBhMegPspCr2BcmC/m/N40+PjBMDaHSzeNE2SyIuyflLC7GhQvHnk -cQXkqJVNC1yesV7zYKDV/xYPI0NxN0kE+4eR650A77jso4gloRUek0cpU4ztpe6Z -z4za7AEKHmZO8pVHpQJihbNMhItbo6BcgeOFWImXyJfcbCtu1ayciaJ0Q45Z1btu -F2wFwQjwZGt7DAvbzYwMBBiTpGxig/8kzibm7bL1Td7huW6Knqbfh4/v+2m+2aNK -1u0TfncFUr17wDDfeVj/xeNOSbPu2X/AppjVX0rxmvWN+AByFfAuw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8UL6st6/4RDkQ2D5ifRG3KImG +s522HRLBlhtYadRiZPSAai0vCPNOomnIKZHf2uO0nh34eWkGYpJlLCW2ScwV2wjL +RJtbdhqceUX+WZaiaF1hYfAtGvGzj9hNbgFoUdOkJXgz2mFVc2XjUq00zLwAnDC7 +nNJ6sIhn1Zhr6nMc9VUNmfAZ/tugbPECggEAC0F2v/i+qoNbKzvjgzPdBTIFkeRw +wvrAeZlWvGJySd9CG7kjMkrHyr5RIfuns5tmhWsmPeMY0zssmW4Yin0uO5cVmoTt +SzmJznty0Tfi2h0gbhbDu0s/lHv7qk8piN+6ITREcmJm6HZxXPWRsgs1YUuxed2L +aFFcXT403kxYIIyngCPWbeZHNrqD23I6KBfJi+/mBVl+/win8O5wmWmX5UDQLohE +Y2bp8nmOqIk3yD+BeCIMQOsCqoWq+Nl0PtEueRhdF4qmvl65KPGPg5d5OzzZHRcG +rHov/p7TM7bCKTGRDqjlYrUgeUDFD7h0wMgBYSvFE2uk7GMo0/aJwc9wPg== -----END rsa private key----- diff --git a/cryptor/rsa_public_example.pem b/cryptor/rsa_public_example.pem index c5909b8..bcdafd2 100644 --- a/cryptor/rsa_public_example.pem +++ b/cryptor/rsa_public_example.pem @@ -1,14 +1,14 @@ -----BEGIN rsa public key----- -MIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEAwGdN8KE2NTK41cVN7i6m -ZZS5J86gjNs0LJDHylb2GG+K4O8sfq98EMKMJ2xGnKoVRJXucVohr5Eiuf5zgxQe -9mpYDyDQ0vnpBkoNkfzJNZQvcQFaIllUeH+eN4hSBhMegPspCr2BcmC/m/N40+Pj -BMDaHSzeNE2SyIuyflLC7GhQvHnkcQXkqJVNC1yesV7zYKDV/xYPI0NxN0kE+4eR -650A77jso4gloRUek0cpU4ztpe6Zz4za7AEKHmZO8pVHpQJihbNMhItbo6BcgeOF -WImXyJfcbCtu1ayciaJ0Q45Z1btuF2wFwQjwZGt7DAvbzYwMBBiTpGxig/8kzibm -7bL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6AJMnILHBGQQ5P3NQsCAwEAAQ== -----END rsa public key----- diff --git a/datetime/datetime.go b/datetime/datetime.go index 67e1474..a9a3814 100644 --- a/datetime/datetime.go +++ b/datetime/datetime.go @@ -445,7 +445,7 @@ func GenerateDatetimesBetween(start, end time.Time, layout string, interval stri } // Min returns the earliest time among the given times. -// Play: todo +// Play: https://go.dev/play/p/MCIDvHNOGGb func Min(t1 time.Time, times ...time.Time) time.Time { minTime := t1 @@ -459,7 +459,7 @@ func Min(t1 time.Time, times ...time.Time) time.Time { } // Max returns the latest time among the given times. -// Play: todo +// Play: https://go.dev/play/p/9m6JMk1LB7- func Max(t1 time.Time, times ...time.Time) time.Time { maxTime := t1 @@ -473,7 +473,7 @@ func Max(t1 time.Time, times ...time.Time) time.Time { } // MaxMin returns the latest and earliest time among the given times. -// Play: todo +// Play: https://go.dev/play/p/rbW51cDtM_2 func MaxMin(t1 time.Time, times ...time.Time) (maxTime time.Time, minTime time.Time) { maxTime = t1 minTime = t1 diff --git a/docs/api/packages/convertor.md b/docs/api/packages/convertor.md index 44354c6..ae9d2f8 100644 --- a/docs/api/packages/convertor.md +++ b/docs/api/packages/convertor.md @@ -1155,7 +1155,7 @@ func main() {

将整数值转换为bigInt。

-函数签名:[运行](todo) +函数签名:[运行](https://go.dev/play/p/X3itkCxwB_x) ```go func ToBigInt[T any](v T) (*big.Int, error) diff --git a/docs/api/packages/cryptor.md b/docs/api/packages/cryptor.md index b246428..fa81262 100644 --- a/docs/api/packages/cryptor.md +++ b/docs/api/packages/cryptor.md @@ -1436,7 +1436,7 @@ func main() { func RsaEncrypt(data []byte, pubKeyFileName string) []byte ``` -示例:[运行](https://go.dev/play/p/uef0q1fz53I) +示例:[运行](https://go.dev/play/p/7_zo6mrx-eX) ```go package main @@ -1473,7 +1473,7 @@ func main() { func RsaDecrypt(data []byte, privateKeyFileName string) []byte ``` -示例:[运行](https://go.dev/play/p/uef0q1fz53I) +示例:[运行](https://go.dev/play/p/7_zo6mrx-eX) ```go package main @@ -1621,7 +1621,7 @@ func main() { func RsaSign(hash crypto.Hash, data []byte, privateKeyFileName string) ([]byte, error) ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/qhsbf8BJ6Mf) ```go package main @@ -1638,12 +1638,12 @@ func main() { privateKey := "./rsa_private.pem" publicKey := "./rsa_public.pem" - signature, err := RsaSign(hash, data, privateKey) + signature, err := cryptor.RsaSign(hash, data, privateKey) if err != nil { return } - err = RsaVerifySign(hash, data, signature, publicKey) + err = cryptor.RsaVerifySign(hash, data, signature, publicKey) if err != nil { return } @@ -1660,7 +1660,7 @@ func main() { func RsaVerifySign(hash crypto.Hash, data, signature []byte, pubKeyFileName string) error ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/qhsbf8BJ6Mf) ```go package main @@ -1677,12 +1677,12 @@ func main() { privateKey := "./rsa_private.pem" publicKey := "./rsa_public.pem" - signature, err := RsaSign(hash, data, privateKey) + signature, err := cryptor.RsaSign(hash, data, privateKey) if err != nil { return } - err = RsaVerifySign(hash, data, signature, publicKey) + err = cryptor.RsaVerifySign(hash, data, signature, publicKey) if err != nil { return } diff --git a/docs/api/packages/datetime.md b/docs/api/packages/datetime.md index 6085f6c..ad22fdf 100644 --- a/docs/api/packages/datetime.md +++ b/docs/api/packages/datetime.md @@ -1585,7 +1585,7 @@ func main() { func Min(t1 time.Time, times ...time.Time) time.Time ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/MCIDvHNOGGb) ```go package main @@ -1615,7 +1615,7 @@ func main() { func Max(t1 time.Time, times ...time.Time) time.Time ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/9m6JMk1LB7-) ```go package main @@ -1645,7 +1645,7 @@ func main() { func MaxMin(t1 time.Time, times ...time.Time) (maxTime time.Time, minTime time.Time) ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/rbW51cDtM_2) ```go package main diff --git a/docs/api/packages/fileutil.md b/docs/api/packages/fileutil.md index 762cd71..e78efc9 100644 --- a/docs/api/packages/fileutil.md +++ b/docs/api/packages/fileutil.md @@ -1088,7 +1088,7 @@ func main() { func GetExeOrDllVersion(filePath string) (string, error) ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/iLRrDBhE38E) ```go package main diff --git a/docs/api/packages/mathutil.md b/docs/api/packages/mathutil.md index 40bce9c..e3a6914 100644 --- a/docs/api/packages/mathutil.md +++ b/docs/api/packages/mathutil.md @@ -1178,7 +1178,7 @@ func main() { func Variance[T constraints.Float | constraints.Integer](numbers []T) float64 ``` -示例:[示例](todo) +示例:[示例](https://go.dev/play/p/uHuV4YgXf8F) ```go package main @@ -1211,7 +1211,7 @@ func main() { func StdDev[T constraints.Float | constraints.Integer](numbers []T) float64 ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/FkNZDXvHD2l) ```go package main @@ -1222,8 +1222,8 @@ import ( ) func main() { - result1 := mathutil.T运行cRound(mathutil.StdDev([]int{1, 2, 3, 4, 5}), 2) - result2 := mathutil.T运行cRound(mathutil.StdDev([]float64{1.1, 2.2, 3.3, 4.4, 5.5}), 2) + result1 := mathutil.TruncRound(mathutil.StdDev([]int{1, 2, 3, 4, 5}), 2) + result2 := mathutil.TruncRound(mathutil.StdDev([]float64{1.1, 2.2, 3.3, 4.4, 5.5}), 2) fmt.Println(result1) fmt.Println(result2) @@ -1244,7 +1244,7 @@ func main() { func Permutation(n, k uint) uint ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/MgobwH_FOxj) ```go package main @@ -1277,7 +1277,7 @@ func main() { func Combination(n, k uint) uint ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/ENFQRDQUFi9) ```go package main diff --git a/docs/api/packages/random.md b/docs/api/packages/random.md index 75916b4..3c2aa83 100644 --- a/docs/api/packages/random.md +++ b/docs/api/packages/random.md @@ -534,7 +534,7 @@ func main() { func RandNumberOfLength(len int) int ``` -实例:[运行](todo) +实例:[运行](https://go.dev/play/p/oyZbuV7bu7b) ```go package main diff --git a/docs/api/packages/slice.md b/docs/api/packages/slice.md index 4378029..00080ab 100644 --- a/docs/api/packages/slice.md +++ b/docs/api/packages/slice.md @@ -2999,7 +2999,7 @@ func main() { func JoinFunc[T any](slice []T, sep string, transform func(T) T) string ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/55ib3SB5fM2) ```go import ( @@ -3029,7 +3029,7 @@ func main() { func ConcatBy[T any](slice []T, sep T, connector func(T, T) T) T ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/6QcUpcY4UMW) ```go import ( diff --git a/docs/api/packages/stream.md b/docs/api/packages/stream.md index f9263fa..ea4a409 100644 --- a/docs/api/packages/stream.md +++ b/docs/api/packages/stream.md @@ -951,7 +951,7 @@ func main() { func (s Stream[T]) IndexOf(target T, equal func(a, b T) bool) int ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/tBV5Nc-XDX2) ```go import ( @@ -984,7 +984,7 @@ func main() { func (s Stream[T]) LastIndexOf(target T, equal func(a, b T) bool) int ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/CjeoNw2eac_G) ```go import ( diff --git a/docs/api/packages/strutil.md b/docs/api/packages/strutil.md index 85023fc..c2cc4e6 100644 --- a/docs/api/packages/strutil.md +++ b/docs/api/packages/strutil.md @@ -1741,7 +1741,7 @@ func main() { func ExtractContent(s, start, end string) []string ``` -示例:[Run](todo) +示例:[Run](https://go.dev/play/p/Ay9UIk7Rum9) ```go import ( diff --git a/docs/api/packages/xerror.md b/docs/api/packages/xerror.md index 164a507..d17df7a 100644 --- a/docs/api/packages/xerror.md +++ b/docs/api/packages/xerror.md @@ -509,7 +509,7 @@ func (tc *TryCatch) Finally(finallyFunc func(ctx context.Context)) *TryCatch func (tc *TryCatch) Do() ``` -示例:[运行](todo) +示例:[运行](https://go.dev/play/p/D5Mdb0mRj0P) ```go package main @@ -529,8 +529,6 @@ func main() { return errors.New("error in try block") }).Catch(func(ctx context.Context, err error) { calledCatch = true - // Error in try block at /path/xxx.go:{line_number} - Cause: error message - // fmt.Println(err.Error()) }).Finally(func(ctx context.Context) { calledFinally = true }).Do() diff --git a/docs/en/api/packages/convertor.md b/docs/en/api/packages/convertor.md index a7a8eed..44c80c7 100644 --- a/docs/en/api/packages/convertor.md +++ b/docs/en/api/packages/convertor.md @@ -1123,7 +1123,7 @@ func main() {

Converts an integer of any supported type (int, int64, uint64, etc.) to *big.Int

-Signature:[Run](todo) +Signature:[Run](https://go.dev/play/p/X3itkCxwB_x) ```go func ToBigInt[T any](v T) (*big.Int, error) diff --git a/docs/en/api/packages/cryptor.md b/docs/en/api/packages/cryptor.md index af0f502..9f1de9d 100644 --- a/docs/en/api/packages/cryptor.md +++ b/docs/en/api/packages/cryptor.md @@ -1435,7 +1435,7 @@ func main() { func RsaEncrypt(data []byte, pubKeyFileName string) []byte ``` -Example:[Run](https://go.dev/play/p/uef0q1fz53I) +Example:[Run](https://go.dev/play/p/7_zo6mrx-eX) ```go package main @@ -1472,7 +1472,7 @@ func main() { func RsaDecrypt(data []byte, privateKeyFileName string) []byte ``` -Example:[Run](https://go.dev/play/p/uef0q1fz53I) +Example:[Run](https://go.dev/play/p/7_zo6mrx-eX) ```go package main @@ -1620,7 +1620,7 @@ func main() { func RsaSign(hash crypto.Hash, data []byte, privateKeyFileName string) ([]byte, error) ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/qhsbf8BJ6Mf) ```go package main @@ -1659,7 +1659,7 @@ func main() { func RsaVerifySign(hash crypto.Hash, data, signature []byte, pubKeyFileName string) error ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/qhsbf8BJ6Mf) ```go package main diff --git a/docs/en/api/packages/datetime.md b/docs/en/api/packages/datetime.md index c87a844..a5fbca4 100644 --- a/docs/en/api/packages/datetime.md +++ b/docs/en/api/packages/datetime.md @@ -1586,7 +1586,7 @@ func main() { func Min(t1 time.Time, times ...time.Time) time.Time ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/MCIDvHNOGGb) ```go package main @@ -1616,7 +1616,7 @@ func main() { func Max(t1 time.Time, times ...time.Time) time.Time ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/9m6JMk1LB7-) ```go package main @@ -1646,7 +1646,7 @@ func main() { func MaxMin(t1 time.Time, times ...time.Time) (maxTime time.Time, minTime time.Time) ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/rbW51cDtM_2) ```go package main diff --git a/docs/en/api/packages/fileutil.md b/docs/en/api/packages/fileutil.md index 54b7686..213dee9 100644 --- a/docs/en/api/packages/fileutil.md +++ b/docs/en/api/packages/fileutil.md @@ -1087,7 +1087,7 @@ func main() { func GetExeOrDllVersion(filePath string) (string, error) ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/iLRrDBhE38E) ```go package main diff --git a/docs/en/api/packages/mathutil.md b/docs/en/api/packages/mathutil.md index 38486c4..61ec2be 100644 --- a/docs/en/api/packages/mathutil.md +++ b/docs/en/api/packages/mathutil.md @@ -1177,7 +1177,7 @@ func main() { func Variance[T constraints.Float | constraints.Integer](numbers []T) float64 ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/uHuV4YgXf8F) ```go package main @@ -1210,7 +1210,7 @@ func main() { func StdDev[T constraints.Float | constraints.Integer](numbers []T) float64 ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/FkNZDXvHD2l) ```go package main @@ -1243,7 +1243,7 @@ func main() { func Permutation(n, k uint) uint ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/MgobwH_FOxj) ```go package main @@ -1276,7 +1276,7 @@ func main() { func Combination(n, k uint) uint ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/ENFQRDQUFi9) ```go package main diff --git a/docs/en/api/packages/random.md b/docs/en/api/packages/random.md index 5ef0da1..9ef1592 100644 --- a/docs/en/api/packages/random.md +++ b/docs/en/api/packages/random.md @@ -536,7 +536,7 @@ func main() { func RandNumberOfLength(len int) int ``` -Signature:[Run](todo) +Signature:[Run](https://go.dev/play/p/oyZbuV7bu7b) ```go package main diff --git a/docs/en/api/packages/slice.md b/docs/en/api/packages/slice.md index a3f80d2..e26a1ed 100644 --- a/docs/en/api/packages/slice.md +++ b/docs/en/api/packages/slice.md @@ -2995,7 +2995,7 @@ func main() { func JoinFunc[T any](slice []T, sep string, transform func(T) T) string ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/55ib3SB5fM2) ```go import ( @@ -3025,7 +3025,7 @@ func main() { func ConcatBy[T any](slice []T, sep T, connector func(T, T) T) T ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/6QcUpcY4UMW) ```go import ( diff --git a/docs/en/api/packages/stream.md b/docs/en/api/packages/stream.md index c652a54..2364232 100644 --- a/docs/en/api/packages/stream.md +++ b/docs/en/api/packages/stream.md @@ -950,7 +950,7 @@ func main() { func (s Stream[T]) IndexOf(target T, equal func(a, b T) bool) int ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/tBV5Nc-XDX2) ```go import ( @@ -983,7 +983,7 @@ func main() { func (s Stream[T]) LastIndexOf(target T, equal func(a, b T) bool) int ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/CjeoNw2eac_G) ```go import ( diff --git a/docs/en/api/packages/strutil.md b/docs/en/api/packages/strutil.md index d8c905a..3e98521 100644 --- a/docs/en/api/packages/strutil.md +++ b/docs/en/api/packages/strutil.md @@ -1743,7 +1743,7 @@ func main() { func ExtractContent(s, start, end string) []string ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/Ay9UIk7Rum9) ```go import ( diff --git a/docs/en/api/packages/xerror.md b/docs/en/api/packages/xerror.md index bdf96db..364e821 100644 --- a/docs/en/api/packages/xerror.md +++ b/docs/en/api/packages/xerror.md @@ -507,7 +507,7 @@ func (tc *TryCatch) Finally(finallyFunc func(ctx context.Context)) *TryCatch func (tc *TryCatch) Do() ``` -Example:[Run](todo) +Example:[Run](https://go.dev/play/p/D5Mdb0mRj0P) ```go package main diff --git a/fileutil/file_windows.go b/fileutil/file_windows.go index 7a2eefe..cad0c98 100644 --- a/fileutil/file_windows.go +++ b/fileutil/file_windows.go @@ -26,7 +26,7 @@ type tagVS_FIXEDFILEINFO struct { } // GetExeOrDllVersion get the version of exe or dll file on windows. -// Play: todo +// Play: https://go.dev/play/p/iLRrDBhE38E func GetExeOrDllVersion(filePath string) (string, error) { // 加载系统dll versionDLL := syscall.NewLazyDLL("version.dll") diff --git a/mathutil/mathutil.go b/mathutil/mathutil.go index 148d3f3..11fc9dc 100644 --- a/mathutil/mathutil.go +++ b/mathutil/mathutil.go @@ -400,7 +400,7 @@ func Div[T constraints.Float | constraints.Integer](x T, y T) float64 { } // Variance returns the variance of numbers. -// Play: todo +// Play: https://go.dev/play/p/uHuV4YgXf8F func Variance[T constraints.Float | constraints.Integer](numbers []T) float64 { n := len(numbers) if n == 0 { @@ -418,13 +418,13 @@ func Variance[T constraints.Float | constraints.Integer](numbers []T) float64 { } // StdDev returns the standard deviation of numbers. -// Play: todo +// Play: https://go.dev/play/p/FkNZDXvHD2l func StdDev[T constraints.Float | constraints.Integer](numbers []T) float64 { return math.Sqrt(Variance(numbers)) } // Permutation calculate P(n, k). -// Play: todo +// Play: https://go.dev/play/p/MgobwH_FOxj func Permutation(n, k uint) uint { if n < k { return 0 @@ -437,7 +437,7 @@ func Permutation(n, k uint) uint { } // Combination calculate C(n, k). -// Play: todo +// Play: https://go.dev/play/p/ENFQRDQUFi9 func Combination(n, k uint) uint { if n < k { return 0 diff --git a/random/random.go b/random/random.go index e942563..ae0c258 100644 --- a/random/random.go +++ b/random/random.go @@ -335,7 +335,7 @@ func UUIdV4() (string, error) { } // RandNumberOfLength 生成一个长度为len的随机数 -// Play: todo +// Play: https://go.dev/play/p/oyZbuV7bu7b func RandNumberOfLength(len int) int { m := int(math.Pow10(len) - 1) i := int(math.Pow10(len - 1)) diff --git a/slice/slice.go b/slice/slice.go index 3ea8c33..4208eba 100644 --- a/slice/slice.go +++ b/slice/slice.go @@ -1415,7 +1415,7 @@ func Frequency[T comparable](slice []T) map[T]int { } // JoinFunc joins the slice elements into a single string with the given separator. -// Play: todo +// Play: https://go.dev/play/p/55ib3SB5fM2 func JoinFunc[T any](slice []T, sep string, transform func(T) T) string { var buf strings.Builder for i, v := range slice { @@ -1428,7 +1428,7 @@ func JoinFunc[T any](slice []T, sep string, transform func(T) T) string { } // ConcatBy concats the elements of a slice into a single value using the provided separator and connector function. -// Play: todo +// Play: https://go.dev/play/p/6QcUpcY4UMW func ConcatBy[T any](slice []T, sep T, connector func(T, T) T) T { var result T diff --git a/stream/stream.go b/stream/stream.go index f49792a..d052aa0 100644 --- a/stream/stream.go +++ b/stream/stream.go @@ -130,7 +130,6 @@ func (s Stream[T]) Distinct() Stream[T] { distinct := map[string]bool{} for _, v := range s.source { - // todo: performance issue k := hashKey(v) if _, ok := distinct[k]; !ok { distinct[k] = true @@ -395,6 +394,7 @@ func (s Stream[T]) Min(less func(a, b T) bool) (T, bool) { } // IndexOf returns the index of the first occurrence of the specified element in this stream, or -1 if this stream does not contain the element. +// Play: https://go.dev/play/p/tBV5Nc-XDX2 func (s Stream[T]) IndexOf(target T, equal func(a, b T) bool) int { for i, v := range s.source { if equal(v, target) { @@ -405,6 +405,7 @@ func (s Stream[T]) IndexOf(target T, equal func(a, b T) bool) int { } // LastIndexOf returns the index of the last occurrence of the specified element in this stream, or -1 if this stream does not contain the element. +// Play: https://go.dev/play/p/CjeoNw2eac_G func (s Stream[T]) LastIndexOf(target T, equal func(a, b T) bool) int { for i := len(s.source) - 1; i >= 0; i-- { if equal(s.source[i], target) { diff --git a/strutil/string.go b/strutil/string.go index d927fd5..1f614cd 100644 --- a/strutil/string.go +++ b/strutil/string.go @@ -737,7 +737,7 @@ func RegexMatchAllGroups(pattern, str string) [][]string { } // ExtractContent extracts the content between the start and end strings in the source string. -// Play: todo +// Play: https://go.dev/play/p/Ay9UIk7Rum9 func ExtractContent(s, start, end string) []string { result := []string{}