mirror of
https://github.com/duke-git/lancet.git
synced 2026-02-04 12:52:28 +08:00
doc: add play ground demo
This commit is contained in:
@@ -711,12 +711,16 @@ import "github.com/duke-git/lancet/v2/mathutil"
|
|||||||
[[play](https://go.dev/play/p/akLWz0EqOSM)]
|
[[play](https://go.dev/play/p/akLWz0EqOSM)]
|
||||||
- **<big>AngleToRadian</big>** : converts angle value to radian value.
|
- **<big>AngleToRadian</big>** : converts angle value to radian value.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#AngleToRadian)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#AngleToRadian)]
|
||||||
|
[[play](https://go.dev/play/p/CIvlICqrHql)]
|
||||||
- **<big>RadianToAngle</big>** : converts radian value to angle value.
|
- **<big>RadianToAngle</big>** : converts radian value to angle value.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#RadianToAngle)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#RadianToAngle)]
|
||||||
|
[[play](https://go.dev/play/p/dQtmOTUOMgi)]
|
||||||
- **<big>PointDistance</big>** : get two points distance.
|
- **<big>PointDistance</big>** : get two points distance.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#PointDistance)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#PointDistance)]
|
||||||
|
[[play](https://go.dev/play/p/RrG4JIaziM8)]
|
||||||
- **<big>IsPrime</big>** : checks if number is prime number.
|
- **<big>IsPrime</big>** : checks if number is prime number.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#IsPrime)]
|
[[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.
|
### 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)]
|
[[play](https://go.dev/play/p/bj7_odx3vRf)]
|
||||||
- **<big>RemoveNonPrintable</big>** : remove non-printable characters from a string.
|
- **<big>RemoveNonPrintable</big>** : remove non-printable characters from a string.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#RemoveNonPrintable)]
|
[[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.
|
### 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)]
|
[[play](https://go.dev/play/p/E2nt3unlmzP)]
|
||||||
- **<big>IsASCII</big>** : checks if string is all ASCII char.
|
- **<big>IsASCII</big>** : checks if string is all ASCII char.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsASCII)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsASCII)]
|
||||||
|
[[play](https://go.dev/play/p/hfQNPLX0jNa)]
|
||||||
- **<big>IsPrintable</big>** : checks if string is all printable chars.
|
- **<big>IsPrintable</big>** : checks if string is all printable chars.
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator.md#IsPrintable)]
|
[[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.
|
### 21. xerror package implements helpers for errors.
|
||||||
|
|
||||||
|
|||||||
@@ -710,12 +710,16 @@ import "github.com/duke-git/lancet/v2/mathutil"
|
|||||||
[[play](https://go.dev/play/p/akLWz0EqOSM)]
|
[[play](https://go.dev/play/p/akLWz0EqOSM)]
|
||||||
- **<big>AngleToRadian</big>** : 将角度值转为弧度值。
|
- **<big>AngleToRadian</big>** : 将角度值转为弧度值。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#AngleToRadian)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#AngleToRadian)]
|
||||||
|
[[play](https://go.dev/play/p/CIvlICqrHql)]
|
||||||
- **<big>RadianToAngle</big>** : 将弧度值转为角度值。
|
- **<big>RadianToAngle</big>** : 将弧度值转为角度值。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#RadianToAngle)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#RadianToAngle)]
|
||||||
|
[[play](https://go.dev/play/p/dQtmOTUOMgi)]
|
||||||
- **<big>PointDistance</big>** : 计算两个坐标点的距离。
|
- **<big>PointDistance</big>** : 计算两个坐标点的距离。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#PointDistance)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#PointDistance)]
|
||||||
|
[[play](https://go.dev/play/p/RrG4JIaziM8)]
|
||||||
- **<big>IsPrime</big>** : 判断质数。
|
- **<big>IsPrime</big>** : 判断质数。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#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 请求。
|
### 13. netutil 网络包支持获取 ip 地址,发送 http 请求。
|
||||||
|
|
||||||
@@ -1152,6 +1156,7 @@ import "github.com/duke-git/lancet/v2/strutil"
|
|||||||
[[play](https://go.dev/play/p/bj7_odx3vRf)]
|
[[play](https://go.dev/play/p/bj7_odx3vRf)]
|
||||||
- **<big>RemoveNonPrintable</big>** : 删除字符串中不可打印的字符。
|
- **<big>RemoveNonPrintable</big>** : 删除字符串中不可打印的字符。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#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 的相关函数。
|
### 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)]
|
[[play](https://go.dev/play/p/E2nt3unlmzP)]
|
||||||
- **<big>IsASCII</big>** : 验证字符串全部为 ASCII 字符。
|
- **<big>IsASCII</big>** : 验证字符串全部为 ASCII 字符。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsASCII)]
|
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#IsASCII)]
|
||||||
|
[[play](https://go.dev/play/p/hfQNPLX0jNa)]
|
||||||
- **<big>IsPrintable</big>** : 检查字符串是否全部为可打印字符。
|
- **<big>IsPrintable</big>** : 检查字符串是否全部为可打印字符。
|
||||||
[[doc](https://github.com/duke-git/lancet/blob/main/docs/validator_zh-CN.md#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 包实现一些错误处理函数
|
### 21. xerror 包实现一些错误处理函数
|
||||||
|
|
||||||
|
|||||||
@@ -218,21 +218,21 @@ func RangeWithStep[T constraints.Integer | constraints.Float](start, end, step T
|
|||||||
}
|
}
|
||||||
|
|
||||||
// AngleToRadian converts angle value to radian value.
|
// AngleToRadian converts angle value to radian value.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/CIvlICqrHql
|
||||||
func AngleToRadian(angle float64) float64 {
|
func AngleToRadian(angle float64) float64 {
|
||||||
radian := angle * (math.Pi / 180)
|
radian := angle * (math.Pi / 180)
|
||||||
return radian
|
return radian
|
||||||
}
|
}
|
||||||
|
|
||||||
// RadianToAngle converts radian value to angle value.
|
// RadianToAngle converts radian value to angle value.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/dQtmOTUOMgi
|
||||||
func RadianToAngle(radian float64) float64 {
|
func RadianToAngle(radian float64) float64 {
|
||||||
angle := radian * (180 / math.Pi)
|
angle := radian * (180 / math.Pi)
|
||||||
return angle
|
return angle
|
||||||
}
|
}
|
||||||
|
|
||||||
// PointDistance get two points distance.
|
// PointDistance get two points distance.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/RrG4JIaziM8
|
||||||
func PointDistance(x1, y1, x2, y2 float64) float64 {
|
func PointDistance(x1, y1, x2, y2 float64) float64 {
|
||||||
a := x1 - x2
|
a := x1 - x2
|
||||||
b := y1 - y2
|
b := y1 - y2
|
||||||
@@ -242,7 +242,7 @@ func PointDistance(x1, y1, x2, y2 float64) float64 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsPrimes checks if number is prime number.
|
// IsPrimes checks if number is prime number.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/Rdd8UTHZJ7u
|
||||||
func IsPrime(n int) bool {
|
func IsPrime(n int) bool {
|
||||||
if n < 2 {
|
if n < 2 {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ func WordCount(s string) int {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// RemoveNonPrintable remove non-printable characters from a string.
|
// RemoveNonPrintable remove non-printable characters from a string.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/og47F5x_jTZ
|
||||||
func RemoveNonPrintable(str string) string {
|
func RemoveNonPrintable(str string) string {
|
||||||
result := strings.Map(func(r rune) rune {
|
result := strings.Map(func(r rune) rune {
|
||||||
if unicode.IsPrint(r) {
|
if unicode.IsPrint(r) {
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ func IsAllLower(str string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsASCII checks if string is all ASCII char.
|
// IsASCII checks if string is all ASCII char.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/hfQNPLX0jNa
|
||||||
func IsASCII(str string) bool {
|
func IsASCII(str string) bool {
|
||||||
for i := 0; i < len(str); i++ {
|
for i := 0; i < len(str); i++ {
|
||||||
if str[i] > unicode.MaxASCII {
|
if str[i] > unicode.MaxASCII {
|
||||||
@@ -70,7 +70,7 @@ func IsASCII(str string) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// IsPrintable checks if string is all printable chars.
|
// IsPrintable checks if string is all printable chars.
|
||||||
// Play: todo
|
// Play: https://go.dev/play/p/Pe1FE2gdtTP
|
||||||
func IsPrintable(str string) bool {
|
func IsPrintable(str string) bool {
|
||||||
for _, r := range str {
|
for _, r := range str {
|
||||||
if !unicode.IsPrint(r) {
|
if !unicode.IsPrint(r) {
|
||||||
|
|||||||
Reference in New Issue
Block a user