diff --git a/README.md b/README.md
index 2d784c7..257c4d0 100644
--- a/README.md
+++ b/README.md
@@ -1099,10 +1099,16 @@ import "github.com/duke-git/lancet/v2/random"
[[play](https://go.dev/play/p/uBkRSOz73Ec)]
- **RandSymbolChar** : Generate a random symbol char of specified length.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandSymbolChar)]
+ [[play](https://go.dev/play/p/Im6ZJxAykOm)]
+
- **RandFloat** : Generate a random float64 number between [min, max) with specific precision.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandFloat)]
+ [[play](https://go.dev/play/p/zbD_tuobJtr)]
+
- **RandFloats** : Generate a slice of random float64 numbers of length n that do not repeat.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/random.md#RandFloats)]
+ [[play](https://go.dev/play/p/I3yndUQ-rhh)]
+
17. Retry package is for executing a function repeatedly until it was successful or canceled by the context. index
@@ -1348,6 +1354,8 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/lkQ3Ri2NQhV)]
- **Random** : get a random item of slice, return its index, when slice is empty, return -1.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/en/api/packages/slice.md#Random)]
+ [[play](https://go.dev/play/p/UzpGQptWppw)]
+
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
diff --git a/README_zh-CN.md b/README_zh-CN.md
index 70b67be..90b30aa 100644
--- a/README_zh-CN.md
+++ b/README_zh-CN.md
@@ -1100,12 +1100,14 @@ import "github.com/duke-git/lancet/v2/random"
[[play](https://go.dev/play/p/uBkRSOz73Ec)]
- **RandSymbolChar** : 生成给定长度的随机符号字符串。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandSymbolChar)]
- [[play](https://go.dev/play/p/uBkRSOz73Ec)]
+ [[play](https://go.dev/play/p/Im6ZJxAykOm)]
- **RandFloat** : 生成随机float64数字,可以指定范围和精度。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandFloat)]
- [[play](https://go.dev/play/p/uBkRSOz73Ec)]
+ [[play](https://go.dev/play/p/zbD_tuobJtr)]
- **RandFloats** : 生成随机float64数字切片,可以指定长度,范围和精度.
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/random.md#RandFloats)]
+ [[play](https://go.dev/play/p/uBkRSOz73Ec)]
+
17. retry 重试执行函数直到函数运行成功或被 context cancel。 回到目录
@@ -1340,7 +1342,6 @@ import "github.com/duke-git/lancet/v2/slice"
- **Without** : 创建一个不包括所有给定值的切片。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Without)]
[[play](https://go.dev/play/p/bwhEXEypThg)]
-- **KeyBy** :将切片每个元素调用函数后转为 map。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#KeyBy)]
[[play](https://go.dev/play/p/uXod2LWD1Kg)]
- **Join** : 用指定的分隔符链接切片元素。
@@ -1351,6 +1352,8 @@ import "github.com/duke-git/lancet/v2/slice"
[[play](https://go.dev/play/p/lkQ3Ri2NQhV)]
- **Random** : 随机返回切片中元素以及下标, 当切片长度为0时返回下标-1。
[[doc](https://github.com/duke-git/lancet/blob/main/docs/api/packages/slice.md#Random)]
+ [[play](https://go.dev/play/p/UzpGQptWppw)]
+
19. stream 流,该包仅验证简单的 stream 实现,功能有限。 回到目录
diff --git a/docs/api/packages/random.md b/docs/api/packages/random.md
index 4dddac4..546ef9e 100644
--- a/docs/api/packages/random.md
+++ b/docs/api/packages/random.md
@@ -231,7 +231,7 @@ func main() {
func RandSymbolChar(length int) string
```
-示例:
+示例:[Run](https://go.dev/play/p/Im6ZJxAykOm)
```go
package main
@@ -243,7 +243,7 @@ import (
func main() {
randStr := random.RandSymbolChar(6)
- fmt.Println(randStr) //@#(_")
+ fmt.Println(randStr) // 随机特殊字符字符串,例如: @#(_")
}
```
@@ -312,7 +312,7 @@ func main() {
func RandFloat(min, max float64, precision int) float64
```
-实例:
+实例:[运行](https://go.dev/play/p/zbD_tuobJtr)
```go
package main
@@ -338,7 +338,7 @@ func main() {
func RandFloats(n int, min, max float64, precision int) []float64
```
-实例:
+实例:[Run](https://go.dev/play/p/I3yndUQ-rhh)
```go
package main
diff --git a/docs/api/packages/slice.md b/docs/api/packages/slice.md
index 3bd3f4d..b630ba9 100644
--- a/docs/api/packages/slice.md
+++ b/docs/api/packages/slice.md
@@ -2501,7 +2501,7 @@ func main() {
func Random[T any](slice []T) (val T, idx int)
```
-示例:[运行](TODO)
+示例:[运行](https://go.dev/play/p/UzpGQptWppw)
```go
import (
diff --git a/docs/en/api/packages/random.md b/docs/en/api/packages/random.md
index d7cabee..443237b 100644
--- a/docs/en/api/packages/random.md
+++ b/docs/en/api/packages/random.md
@@ -231,7 +231,7 @@ func main() {
func RandSymbolChar(length int) string
```
-Example:
+Example:[Run](https://go.dev/play/p/Im6ZJxAykOm)
```go
package main
@@ -243,7 +243,7 @@ import (
func main() {
randStr := random.RandSymbolChar(6)
- fmt.Println(randStr) //@#(_")
+ fmt.Println(randStr) // random string like: @#(_")
}
```
@@ -313,7 +313,7 @@ func main() {
func RandFloat(min, max float64, precision int) float64
```
-Example:
+Example:[Run](https://go.dev/play/p/zbD_tuobJtr)
```go
package main
@@ -339,7 +339,7 @@ func main() {
func RandFloats(n int, min, max float64, precision int) []float64
```
-Example:
+Example:[Run](https://go.dev/play/p/I3yndUQ-rhh)
```go
package main
@@ -351,6 +351,6 @@ import (
func main() {
floatNumbers := random.RandFloats(5, 1.0, 5.0, 2)
- fmt.Println(floatNumber) //[3.42 3.99 1.3 2.38 4.23] (random)
+ fmt.Println(floatNumbers) //[3.42 3.99 1.3 2.38 4.23] (random)
}
```
\ No newline at end of file
diff --git a/docs/en/api/packages/slice.md b/docs/en/api/packages/slice.md
index 5cb0134..a51822c 100644
--- a/docs/en/api/packages/slice.md
+++ b/docs/en/api/packages/slice.md
@@ -2498,7 +2498,7 @@ func main() {
func Random[T any](slice []T) (val T, idx int)
```
-Example:[Run](TODO)
+Example:[Run](https://go.dev/play/p/UzpGQptWppw)
```go
import (
diff --git a/netutil/net.go b/netutil/net.go
index 307ba00..6b6d090 100644
--- a/netutil/net.go
+++ b/netutil/net.go
@@ -230,7 +230,6 @@ func UploadFile(filepath string, server string) (bool, error) {
}
// DownloadFile will download the file exist in url to a local file.
-// Play: todo
func DownloadFile(filepath string, url string) error {
resp, err := http.Get(url)
if err != nil {
diff --git a/random/random.go b/random/random.go
index fe155dd..37f6289 100644
--- a/random/random.go
+++ b/random/random.go
@@ -41,7 +41,7 @@ func RandInt(min, max int) int {
}
// RandFloat generate random float64 number between [min, max) with specific precision.
-// Play: todo
+// Play: https://go.dev/play/p/zbD_tuobJtr
func RandFloat(min, max float64, precision int) float64 {
if min == max {
return min
@@ -103,7 +103,7 @@ func RandNumeralOrLetter(length int) string {
// RandSymbolChar generate a random symbol char of specified length.
// symbol chars: !@#$%^&*()_+-=[]{}|;':\",./<>?.
-// Play: todo
+// Play: https://go.dev/play/p/Im6ZJxAykOm
func RandSymbolChar(length int) string {
return random(SymbolChars, length)
}
@@ -164,7 +164,7 @@ func RandUniqueIntSlice(n, min, max int) []int {
}
// RandFloats generate a slice of random float64 numbers of length n that do not repeat.
-// Play: todo
+// Play: https://go.dev/play/p/I3yndUQ-rhh
func RandFloats(n int, min, max float64, precision int) []float64 {
nums := make([]float64, n)
used := make(map[float64]struct{}, n)
diff --git a/slice/slice.go b/slice/slice.go
index fd10970..fbae883 100644
--- a/slice/slice.go
+++ b/slice/slice.go
@@ -1232,7 +1232,7 @@ func Partition[T any](slice []T, predicates ...func(item T) bool) [][]T {
}
// Random get a random item of slice, return idx=-1 when slice is empty
-// Play: todo
+// Play: https://go.dev/play/p/UzpGQptWppw
func Random[T any](slice []T) (val T, idx int) {
if len(slice) == 0 {
return val, -1