diff --git a/README.md b/README.md index 42037bf..527b438 100644 --- a/README.md +++ b/README.md @@ -711,12 +711,16 @@ import "github.com/duke-git/lancet/v2/mathutil" [[play](https://go.dev/play/p/akLWz0EqOSM)] - **AngleToRadian** : converts angle value to radian value. [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#AngleToRadian)] + [[play](https://go.dev/play/p/CIvlICqrHql)] - **RadianToAngle** : converts radian value to angle value. [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#RadianToAngle)] + [[play](https://go.dev/play/p/dQtmOTUOMgi)] - **PointDistance** : get two points distance. [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#PointDistance)] + [[play](https://go.dev/play/p/RrG4JIaziM8)] - **IsPrime** : checks if number is prime number. [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#IsPrime)] + [[play](https://go.dev/play/p/Rdd8UTHZJ7u)] ### 13. Netutil package contains functions to get net information and send http request. @@ -1150,6 +1154,8 @@ import "github.com/duke-git/lancet/v2/strutil" [[play](https://go.dev/play/p/bj7_odx3vRf)] - **RemoveNonPrintable** : remove non-printable characters from a string. [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#RemoveNonPrintable)] + [[play](https://go.dev/play/p/og47F5x_jTZ)] + ### 19. System package contain some functions about os, runtime, shell command. @@ -1281,8 +1287,10 @@ import "github.com/duke-git/lancet/v2/validator" [[play](https://go.dev/play/p/E2nt3unlmzP)] - **IsASCII** : checks if string is all ASCII char. [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsASCII)] + [[play](https://go.dev/play/p/hfQNPLX0jNa)] - **IsPrintable** : checks if string is all printable chars. [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsPrintable)] + [[play](https://go.dev/play/p/Pe1FE2gdtTP)] ### 21. xerror package implements helpers for errors. diff --git a/README_zh-CN.md b/README_zh-CN.md index a26a17c..f07e1b2 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -710,12 +710,16 @@ import "github.com/duke-git/lancet/v2/mathutil" [[play](https://go.dev/play/p/akLWz0EqOSM)] - **AngleToRadian** : 将角度值转为弧度值。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#AngleToRadian)] + [[play](https://go.dev/play/p/CIvlICqrHql)] - **RadianToAngle** : 将弧度值转为角度值。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#RadianToAngle)] + [[play](https://go.dev/play/p/dQtmOTUOMgi)] - **PointDistance** : 计算两个坐标点的距离。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#PointDistance)] + [[play](https://go.dev/play/p/RrG4JIaziM8)] - **IsPrime** : 判断质数。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#IsPrime)] + [[play](https://go.dev/play/p/Rdd8UTHZJ7u)] ### 13. netutil 网络包支持获取 ip 地址,发送 http 请求。 @@ -1152,6 +1156,7 @@ import "github.com/duke-git/lancet/v2/strutil" [[play](https://go.dev/play/p/bj7_odx3vRf)] - **RemoveNonPrintable** : 删除字符串中不可打印的字符。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#RemoveNonPrintable)] + [[play](https://go.dev/play/p/og47F5x_jTZ)] ### 19. system 包含 os, runtime, shell command 的相关函数。 @@ -1283,8 +1288,10 @@ import "github.com/duke-git/lancet/v2/validator" [[play](https://go.dev/play/p/E2nt3unlmzP)] - **IsASCII** : 验证字符串全部为 ASCII 字符。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsASCII)] + [[play](https://go.dev/play/p/hfQNPLX0jNa)] - **IsPrintable** : 检查字符串是否全部为可打印字符。 [[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsPrintable)] + [[play](https://go.dev/play/p/Pe1FE2gdtTP)] ### 21. xerror 包实现一些错误处理函数 diff --git a/mathutil/mathutil.go b/mathutil/mathutil.go index b404ebe..c97967c 100644 --- a/mathutil/mathutil.go +++ b/mathutil/mathutil.go @@ -218,21 +218,21 @@ func RangeWithStep[T constraints.Integer | constraints.Float](start, end, step T } // AngleToRadian converts angle value to radian value. -// Play: todo +// Play: https://go.dev/play/p/CIvlICqrHql func AngleToRadian(angle float64) float64 { radian := angle * (math.Pi / 180) return radian } // RadianToAngle converts radian value to angle value. -// Play: todo +// Play: https://go.dev/play/p/dQtmOTUOMgi func RadianToAngle(radian float64) float64 { angle := radian * (180 / math.Pi) return angle } // PointDistance get two points distance. -// Play: todo +// Play: https://go.dev/play/p/RrG4JIaziM8 func PointDistance(x1, y1, x2, y2 float64) float64 { a := x1 - x2 b := y1 - y2 @@ -242,7 +242,7 @@ func PointDistance(x1, y1, x2, y2 float64) float64 { } // IsPrimes checks if number is prime number. -// Play: todo +// Play: https://go.dev/play/p/Rdd8UTHZJ7u func IsPrime(n int) bool { if n < 2 { return false diff --git a/strutil/string.go b/strutil/string.go index 5427812..73b48e2 100644 --- a/strutil/string.go +++ b/strutil/string.go @@ -362,7 +362,7 @@ func WordCount(s string) int { } // RemoveNonPrintable remove non-printable characters from a string. -// Play: todo +// Play: https://go.dev/play/p/og47F5x_jTZ func RemoveNonPrintable(str string) string { result := strings.Map(func(r rune) rune { if unicode.IsPrint(r) { diff --git a/validator/validator.go b/validator/validator.go index 1f2b0bf..abc2b5c 100644 --- a/validator/validator.go +++ b/validator/validator.go @@ -59,7 +59,7 @@ func IsAllLower(str string) bool { } // IsASCII checks if string is all ASCII char. -// Play: todo +// Play: https://go.dev/play/p/hfQNPLX0jNa func IsASCII(str string) bool { for i := 0; i < len(str); i++ { if str[i] > unicode.MaxASCII { @@ -70,7 +70,7 @@ func IsASCII(str string) bool { } // IsPrintable checks if string is all printable chars. -// Play: todo +// Play: https://go.dev/play/p/Pe1FE2gdtTP func IsPrintable(str string) bool { for _, r := range str { if !unicode.IsPrint(r) {