1
0
mirror of https://github.com/duke-git/lancet.git synced 2026-02-09 15:12:26 +08:00

doc: add go playground demo

This commit is contained in:
dudaodong
2024-03-06 14:52:35 +08:00
parent 036847577d
commit 1b31014f81
14 changed files with 86 additions and 56 deletions

View File

@@ -891,7 +891,7 @@ func main() {
func ToStdBase64(value any) string
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/_fLJqJD3NMo)</span></b>
```go
package main
@@ -963,7 +963,7 @@ func main() {
func ToUrlBase64(value any) string
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/C_d0GlvEeUR)</span></b>
```go
package main
@@ -1032,7 +1032,7 @@ func main() {
func ToRawStdBase64(value any) string
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/wSAr3sfkDcv)</span></b>
```go
package main
@@ -1064,7 +1064,7 @@ func main() {
fmt.Println(afterEncode)
floatVal := 123.456
afterEncode = convertor.ToRawStdBase64(floatVal)
afterEncode := convertor.ToRawStdBase64(floatVal)
fmt.Println(afterEncode)
boolVal := true
@@ -1090,7 +1090,7 @@ func main() {
<p>值转换为 ToRawUrlBase64 编码的字符串。error 类型的数据也会把 error 的原因进行编码,复杂的结构会转为 JSON 格式的字符串</p>
<b>函数签名:</b>
<b>函数签名:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/HwdDPFcza1O)</span></b>
```go
func ToRawUrlBase64(value any) string
@@ -1109,7 +1109,7 @@ import (
func main() {
stringVal := "hello"
afterEncode = convertor.ToRawUrlBase64(stringVal)
afterEncode := convertor.ToRawUrlBase64(stringVal)
fmt.Println(afterEncode)
byteSliceVal := []byte("hello")
@@ -1132,11 +1132,11 @@ func main() {
fmt.Println(afterEncode)
boolVal := true
afterEncode = convertor.ToRawStdBase64(boolVal)
afterEncode = convertor.ToRawUrlBase64(boolVal)
fmt.Println(afterEncode)
errVal := errors.New("err")
afterEncode = convertor.ToRawStdBase64(errVal)
afterEncode = convertor.ToRawUrlBase64(errVal)
fmt.Println(afterEncode)
// Output:

View File

@@ -976,7 +976,7 @@ func main() {
func ChunkRead(file *os.File, offset int64, size int, bufPool *sync.Pool) ([]string, error)
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/r0hPmKWhsgf)</span></b>
```go
package main
@@ -1035,7 +1035,7 @@ func main() {
func ParallelChunkRead(filePath string, linesCh chan<- []string, chunkSizeMB, maxGoroutine int) error
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/teMXnCsdSEw)</span></b>
```go
package main

View File

@@ -508,7 +508,7 @@ func main() {
func CeilToFloat[T constraints.Float | constraints.Integer](x T, n int) float64
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/8hOeSADZPCo)</span></b>
```go
package main
@@ -544,7 +544,7 @@ func main() {
func CeilToString[T constraints.Float | constraints.Integer](x T, n int) string
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/wy5bYEyUKKG)</span></b>
```go
package main
@@ -577,10 +577,10 @@ func main() {
<b>函数签名:</b>
```go
func CeilToString[T constraints.Float | constraints.Integer](x T, n int) string
func FloorToFloat[T constraints.Float | constraints.Integer](x T, n int) float64
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/vbCBrQHZEED)</span></b>
```go
package main
@@ -613,10 +613,10 @@ func main() {
<b>函数签名:</b>
```go
func CeilToString[T constraints.Float | constraints.Integer](x T, n int) string
func FloorToString[T constraints.Float | constraints.Integer](x T, n int) string
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/Qk9KPd2IdDb)</span></b>
```go
package main
@@ -1130,7 +1130,7 @@ func main() {
### <span id="Div">Div</span>
<p>除法运算.</p>
<p>除法运算</p>
<b>函数签名:</b>
@@ -1138,7 +1138,7 @@ func main() {
func Div[T constraints.Float | constraints.Integer](x T, y T) float64
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/WLxDdGXXYat)</span></b>
```go
package main
@@ -1156,6 +1156,7 @@ func main() {
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
// Output:
// 2.25
// 0.5

View File

@@ -1475,7 +1475,7 @@ func main() {
func SubInBetween(str string, start string, end string) string
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/EDbaRvjeNsv)</span></b>
```go
import (
@@ -1505,10 +1505,10 @@ func main() {
<b>函数签名:</b>
```go
HammingDistance(a, b string) (int, error)
func HammingDistance(a, b string) (int, error)
```
<b>示例:</b>
<b>示例:<span style="float:right;display:inline-block;">[运行](https://go.dev/play/p/glNdQEA9HUi)</span></b>
```go
import (