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

doc: update slice and convertor document

This commit is contained in:
dudaodong
2022-12-01 11:43:10 +08:00
parent d8ed692651
commit d66f92cd68
4 changed files with 29 additions and 3 deletions

View File

@@ -394,6 +394,32 @@ func main() {
```
### <span id="ToString">ToString</span>
<p>ToString convert value to string, for number, string, []byte, will convert to string. For other type (slice, map, array, struct) will call json.Marshal</p>
<b>Signature:</b>
```go
func ToString(value any) string
```
<b>Example:</b>
```go
package main
import (
"fmt"
"github.com/duke-git/lancet/v2/convertor"
)
func main() {
fmt.Printf("%q", convertor.ToString(1)) //"1"
fmt.Printf("%q", convertor.ToString(1.1)) //"1.1"
fmt.Printf("%q", convertor.ToString([]int{1, 2, 3})) //"[1,2,3]"
}
```
### <span id="StructToMap">StructToMap</span>

View File

@@ -400,7 +400,7 @@ func main() {
### <span id="ToString">ToString</span>
<p>将interface转成字符串</p>
<p>将值转换为字符串,对于数字、字符串、[]byte将转换为字符串。 对于其他类型(切片、映射、数组、结构)将调用 json.Marshal</p>
<b>函数签名:</b>

View File

@@ -185,7 +185,7 @@ func main() {
<b>Signature:</b>
```go
func Compact[T any](slice []T) []T
func Compact[T comparable](slice []T) []T
```
<b>Example:</b>

View File

@@ -188,7 +188,7 @@ func main() {
<b>函数签名:</b>
```go
func Compact[T any](slice []T) []T
func Compact[T comparable](slice []T) []T
```
<b>例子:</b>