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

doc: add go playground demo for compare package

This commit is contained in:
dudaodong
2023-04-27 14:15:25 +08:00
parent f93c561f5d
commit 82cb86b35c
3 changed files with 28 additions and 13 deletions

View File

@@ -128,16 +128,22 @@ import "github.com/duke-git/lancet/v2/compare"
- **<big>Equal</big>** : Checks if two values are equal or not. (check both type and value)
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#Equal)]
[[play](https://go.dev/play/p/wmVxR-to4lz)]
- **<big>EqualValue</big>** : Checks if two values are equal or not. (check value only)
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#EqualValue)]
[[play](https://go.dev/play/p/fxnna_LLD9u)]
- **<big>LessThan</big>** : Checks if value `left` less than value `right`.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#LessThan)]
[[play](https://go.dev/play/p/cYh7FQQj0ne)]
- **<big>GreaterThan</big>** : Checks if value `left` greater than value `right`.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#GreaterThan)]
[[play](https://go.dev/play/p/9-NYDFZmIMp)]
- **<big>LessOrEqual</big>** : Checks if value `left` less than or equal than value `right`.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#LessOrEqual)]
[[play](https://go.dev/play/p/e4T_scwoQzp)]
- **<big>GreaterOrEqual</big>** : Checks if value `left` less greater or equal than value `right`.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare.md#GreaterOrEqual)]
[[play](https://go.dev/play/p/vx8mP0U8DFk)]
### 3. Concurrency package contain some functions to support concurrent programming. eg, goroutine, channel, async.
@@ -581,7 +587,6 @@ import "github.com/duke-git/lancet/v2/fileutil"
[[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#ReadCsvFile)]
[[play](https://go.dev/play/p/OExTkhGEd3_u)]
### 10. Formatter contains some functions for data formatting.
```go
@@ -1341,7 +1346,6 @@ import "github.com/duke-git/lancet/v2/strutil"
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#IndexOffset)]
[[play](https://go.dev/play/p/qZo4lV2fomB)]
### 21. System package contain some functions about os, runtime, shell command.
```go

View File

@@ -127,16 +127,22 @@ import "github.com/duke-git/lancet/v2/compare"
- **<big>Equal</big>** : 检查两个值是否相等(检查类型和值)。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#Equal)]
[[play](https://go.dev/play/p/wmVxR-to4lz)]
- **<big>EqualValue</big>** : 检查两个值是否相等(只检查值)。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#EqualValue)]
[[play](https://go.dev/play/p/fxnna_LLD9u)]
- **<big>LessThan</big>** : 验证参数`left`的值是否小于参数`right`的值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#LessThan)]
[[play](https://go.dev/play/p/cYh7FQQj0ne)]
- **<big>GreaterThan</big>** : 验证参数`left`的值是否大于参数`right`的值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#GreaterThan)]
[[play](https://go.dev/play/p/9-NYDFZmIMp)]
- **<big>LessOrEqual</big>** : 验证参数`left`的值是否小于或等于参数`right`的值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#LessOrEqual)]
[[play](https://go.dev/play/p/e4T_scwoQzp)]
- **<big>GreaterOrEqual</big>** : 验证参数`left`的值是否大于或等于参数`right`的值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/compare_zh-CN.md#GreaterOrEqual)]
[[play](https://go.dev/play/p/vx8mP0U8DFk)]
### 3. concurrency 包含一些支持并发编程的功能。例如goroutine, channel, async 等。
@@ -580,7 +586,6 @@ import "github.com/duke-git/lancet/v2/fileutil"
[[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil_zh-CN.md#ReadCsvFile)]
[[play](https://go.dev/play/p/OExTkhGEd3_u)]
### 10. formatter 格式化器包含一些数据格式化处理方法。
```go

View File

@@ -27,32 +27,38 @@ var (
)
// Equal checks if two values are equal or not. (check both type and value)
// Play: https://go.dev/play/p/wmVxR-to4lz
func Equal(left, right any) bool {
return compareValue(equal, left, right)
}
// EqualValue checks if two values are equal or not. (check value only)
// Play: https://go.dev/play/p/fxnna_LLD9u
func EqualValue(left, right any) bool {
ls, rs := convertor.ToString(left), convertor.ToString(right)
return ls == rs
}
// LessThan checks if value `left` less than value `right`.
// Play: https://go.dev/play/p/cYh7FQQj0ne
func LessThan(left, right any) bool {
return compareValue(lessThan, left, right)
}
// GreaterThan checks if value `left` greater than value `right`.
// Play: https://go.dev/play/p/9-NYDFZmIMp
func GreaterThan(left, right any) bool {
return compareValue(greaterThan, left, right)
}
// LessOrEqual checks if value `left` less than or equal to value `right`.
// Play: https://go.dev/play/p/e4T_scwoQzp
func LessOrEqual(left, right any) bool {
return compareValue(lessOrEqual, left, right)
}
// GreaterOrEqual checks if value `left` greater than or equal to value `right`.
// Play: https://go.dev/play/p/vx8mP0U8DFk
func GreaterOrEqual(left, right any) bool {
return compareValue(greaterOrEqual, left, right)
}