diff --git a/README.md b/README.md
index 1d18c9d..a4f8cc9 100644
--- a/README.md
+++ b/README.md
@@ -493,10 +493,14 @@ import "github.com/duke-git/lancet/v2/datetime"
[[play](https://go.dev/play/p/xS1eS2ejGew)]
- **BetweenSeconds** : returns the number of seconds between two times.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#BetweenSeconds)]
+ [[play](https://go.dev/play/p/n3YDRyfyXJu)]
- **DayOfYear** : returns which day of the year the parameter date `t` is.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#DayOfYear)]
+ [[play](https://go.dev/play/p/0hjqhTwFNlH)]
- **IsWeekend** : checks if passed time is weekend or not.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#IsWeekend)]
+ [[play](https://go.dev/play/p/cupRM5aZOIY)]
+
### 8. Datastructure package constains some common data structure. eg. list, linklist, stack, queue, set, tree, graph.
@@ -603,8 +607,11 @@ import "github.com/duke-git/lancet/v2/fileutil"
[[play](https://go.dev/play/p/OExTkhGEd3_u)]
- **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)]
- **WriteStringToFile** : write string to target file.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/fileutil.md#WriteStringToFile)]
+ [[play](https://go.dev/play/p/GhLS6d8lH_g)]
+
### 10. Formatter contains some functions for data formatting.
@@ -814,8 +821,11 @@ import "github.com/duke-git/lancet/v2/mathutil"
[[play](https://go.dev/play/p/EjcZxfY7G_g)]
- **Cos** : return the cosine of the radian argument.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil.md#Cos)]
+ [[play](https://go.dev/play/p/Sm89LoIfvFq)]
- **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)]
+
### 14. Netutil package contains functions to get net information and send http request.
@@ -1307,8 +1317,10 @@ import "github.com/duke-git/lancet/v2/strutil"
[[play](https://go.dev/play/p/2OAjgbmAqHZ)]
- **ContainsAll** : return true if target string contains all the substrings.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#ContainsAll)]
+ [[play](https://go.dev/play/p/KECtK2Os4zq)]
- **ContainsAny** : return true if target string contains any one of the substrings.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#ContainsAny)]
+ [[play](https://go.dev/play/p/dZGSSMB3LXE)]
- **IsString** : checks if the parameter value data type is string or not.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil.md#IsString)]
[[play](https://go.dev/play/p/IOgq7oF9ERm)]
@@ -1392,6 +1404,8 @@ import "github.com/duke-git/lancet/v2/strutil"
[[play](https://go.dev/play/p/ZNL6o4SkYQ7)]
- **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)]
+
### 21. System package contain some functions about os, runtime, shell command.
diff --git a/README_zh-CN.md b/README_zh-CN.md
index 350bea3..1c94471 100644
--- a/README_zh-CN.md
+++ b/README_zh-CN.md
@@ -495,10 +495,14 @@ import "github.com/duke-git/lancet/v2/datetime"
[[play](https://go.dev/play/p/xS1eS2ejGew)]
- **BetweenSeconds** : 返回两个时间的间隔秒数。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#BetweenSeconds)]
+ [[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime.md#BetweenSeconds)]
- **DayOfYear** : 返回参数日期是一年中的第几天。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/datetime_zh-CN.md#DayOfYear)]
+ [[play](https://go.dev/play/p/0hjqhTwFNlH)]
- **IsWeekend** : 判断日期是否是周末。
[[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.
@@ -605,8 +609,12 @@ import "github.com/duke-git/lancet/v2/fileutil"
[[play](https://go.dev/play/p/OExTkhGEd3_u)]
- **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 格式化器包含一些数据格式化处理方法。
@@ -816,8 +824,11 @@ import "github.com/duke-git/lancet/v2/mathutil"
[[play](https://go.dev/play/p/EjcZxfY7G_g)]
- **Cos** : 计算弧度的余弦值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#Cos)]
+ [[play](https://go.dev/play/p/Sm89LoIfvFq)]
- **Sin** : 计算弧度的正弦值。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/mathutil_zh-CN.md#Sin)]
+ [[play](https://go.dev/play/p/TWMQlMywDsP)]
+
### 14. netutil 网络包支持获取 ip 地址,发送 http 请求。
@@ -1312,8 +1323,10 @@ import "github.com/duke-git/lancet/v2/strutil"
[[play](https://go.dev/play/p/2OAjgbmAqHZ)]
- **ContainsAll** : 判断字符串是否包括全部给定的子字符串切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#ContainsAll)]
+ [[play](https://go.dev/play/p/KECtK2Os4zq)]
- **ContainsAny** : 判断字符串是否包括给定的子字符串切片中任意一个子字符串。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#ContainsAny)]
+ [[play](https://go.dev/play/p/dZGSSMB3LXE)]
- **IsString** : 判断传入参数的数据类型是否为字符串。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#IsString)]
[[play](https://go.dev/play/p/IOgq7oF9ERm)]
@@ -1397,6 +1410,8 @@ import "github.com/duke-git/lancet/v2/strutil"
[[play](https://go.dev/play/p/ZNL6o4SkYQ7)]
- **HideString** : 隐藏源字符串中的一些字符。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/strutil_zh-CN.md#HideString)]
+ [[play](https://go.dev/play/p/pzbaIVCTreZ)]
+
### 21. system 包含 os, runtime, shell command 的相关函数。
diff --git a/datetime/datetime.go b/datetime/datetime.go
index d046a94..178a090 100644
--- a/datetime/datetime.go
+++ b/datetime/datetime.go
@@ -232,14 +232,14 @@ func IsLeapYear(year int) bool {
}
// BetweenSeconds returns the number of seconds between two times.
-// Play: todo
+// Play: https://go.dev/play/p/n3YDRyfyXJu
func BetweenSeconds(t1 time.Time, t2 time.Time) int64 {
index := t2.Unix() - t1.Unix()
return index
}
// DayOfYear returns which day of the year the parameter date `t` is.
-// Play: todo
+// Play: https://go.dev/play/p/0hjqhTwFNlH
func DayOfYear(t time.Time) int {
y, m, d := t.Date()
firstDay := time.Date(y, 1, 1, 0, 0, 0, 0, t.Location())
@@ -249,7 +249,7 @@ func DayOfYear(t time.Time) int {
}
// IsWeekend checks if passed time is weekend or not.
-// Play: todo
+// Play: https://go.dev/play/p/cupRM5aZOIY
func IsWeekend(t time.Time) bool {
return time.Saturday == t.Weekday() || time.Sunday == t.Weekday()
}
diff --git a/docs/datetime.md b/docs/datetime.md
index ea68f63..0087ed8 100644
--- a/docs/datetime.md
+++ b/docs/datetime.md
@@ -1163,8 +1163,8 @@ import (
func main() {
today := time.Now()
- tomorrow := AddDay(today, 1)
- yesterday := AddDay(today, -1)
+ tomorrow := datetime.AddDay(today, 1)
+ yesterday := datetime.AddDay(today, -1)
result1 := datetime.BetweenSeconds(today, tomorrow)
result2 := datetime.BetweenSeconds(today, yesterday)
diff --git a/docs/datetime_zh-CN.md b/docs/datetime_zh-CN.md
index 54a69f6..8b9e901 100644
--- a/docs/datetime_zh-CN.md
+++ b/docs/datetime_zh-CN.md
@@ -1162,8 +1162,8 @@ import (
func main() {
today := time.Now()
- tomorrow := AddDay(today, 1)
- yesterday := AddDay(today, -1)
+ tomorrow := datetime.AddDay(today, 1)
+ yesterday := datetime.AddDay(today, -1)
result1 := datetime.BetweenSeconds(today, tomorrow)
result2 := datetime.BetweenSeconds(today, yesterday)
diff --git a/fileutil/file.go b/fileutil/file.go
index 7db1685..ceea46d 100644
--- a/fileutil/file.go
+++ b/fileutil/file.go
@@ -455,7 +455,7 @@ func ReadCsvFile(filepath string) ([][]string, error) {
}
// WriteStringToFile write string to target file.
-// Play: todo
+// Play: https://go.dev/play/p/GhLS6d8lH_g
func WriteStringToFile(filepath string, content string, append bool) error {
flag := os.O_RDWR | os.O_CREATE
if append {
@@ -473,7 +473,7 @@ func WriteStringToFile(filepath string, content string, append bool) error {
}
// WriteBytesToFile write bytes to target file.
-// Play: todo
+// Play: https://go.dev/play/p/s7QlDxMj3P8
func WriteBytesToFile(filepath string, content []byte) error {
f, err := os.OpenFile(filepath, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0644)
if err != nil {
diff --git a/mathutil/mathutil.go b/mathutil/mathutil.go
index b919ee6..eb7d13f 100644
--- a/mathutil/mathutil.go
+++ b/mathutil/mathutil.go
@@ -303,7 +303,7 @@ func lcm[T constraints.Integer](a, b T) T {
}
// Cos returns the cosine of the radian argument.
-// Play: todo
+// Play: https://go.dev/play/p/Sm89LoIfvFq
func Cos(radian float64, precision ...int) float64 {
t := 1.0 / (2.0 * math.Pi)
radian *= t
@@ -319,7 +319,7 @@ func Cos(radian float64, precision ...int) float64 {
}
// Cos returns the sine of the radian argument.
-// Play: todo
+// Play: https://go.dev/play/p/TWMQlMywDsP
func Sin(radian float64, precision ...int) float64 {
return Cos((math.Pi / 2) - radian)
}
diff --git a/strutil/string.go b/strutil/string.go
index c38fe09..0dd2b10 100644
--- a/strutil/string.go
+++ b/strutil/string.go
@@ -504,7 +504,7 @@ func Trim(str string, characterMask ...string) string {
// HideString hide some chars in source string with param `replaceChar`.
// replace range is origin[start : end]. [start, end)
-// Play: todo
+// Play: https://go.dev/play/p/pzbaIVCTreZ)
func HideString(origin string, start, end int, replaceChar string) string {
size := len(origin)
@@ -530,7 +530,7 @@ func HideString(origin string, start, end int, replaceChar string) string {
}
// ContainsAll return true if target string contains all the substrs.
-// Play: todo
+// Play: https://go.dev/play/p/KECtK2Os4zq
func ContainsAll(str string, substrs []string) bool {
for _, v := range substrs {
if !strings.Contains(str, v) {
@@ -542,7 +542,7 @@ func ContainsAll(str string, substrs []string) bool {
}
// ContainsAny return true if target string contains any one of the substrs.
-// Play: todo
+// Play: https://go.dev/play/p/dZGSSMB3LXE
func ContainsAny(str string, substrs []string) bool {
for _, v := range substrs {
if strings.Contains(str, v) {