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

doc: format code in doc file

This commit is contained in:
dudaodong
2023-02-22 17:00:46 +08:00
parent 8e36ef5cef
commit 5eac358bb0
4 changed files with 244 additions and 244 deletions

View File

@@ -652,45 +652,45 @@ import (
func main() {
type Struct struct {
Str string
Int int
Float float64
Bool bool
Nil interface{}
unexported string
}
Str string
Int int
Float float64
Bool bool
Nil interface{}
unexported string
}
cases := []interface{}{
true,
1,
0.1,
map[string]int{
"a": 1,
"b": 2,
},
&Struct{
Str: "test",
Int: 1,
Float: 0.1,
Bool: true,
Nil: nil,
// unexported: "can't be cloned",
},
}
cases := []interface{}{
true,
1,
0.1,
map[string]int{
"a": 1,
"b": 2,
},
&Struct{
Str: "test",
Int: 1,
Float: 0.1,
Bool: true,
Nil: nil,
// unexported: "can't be cloned",
},
}
for _, item := range cases {
cloned := convertor.DeepClone(item)
for _, item := range cases {
cloned := convertor.DeepClone(item)
isPointerEqual := &cloned == &item
fmt.Println(cloned, isPointerEqual)
}
isPointerEqual := &cloned == &item
fmt.Println(cloned, isPointerEqual)
}
// Output:
// true false
// 1 false
// 0.1 false
// map[a:1 b:2] false
// &{test 1 0.1 true <nil> } false
// Output:
// true false
// 1 false
// 0.1 false
// map[a:1 b:2] false
// &{test 1 0.1 true <nil> } false
}
```
@@ -717,43 +717,43 @@ import (
func main() {
type Address struct {
Country string
ZipCode string
}
Country string
ZipCode string
}
type User struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
type User struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
type Employee struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
type Employee struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
user := User{Name: "user001", Age: 10, Role: "Admin", Addr: Address{Country: "CN", ZipCode: "001"}, Hobbys: []string{"a", "b"}, salary: 1000}
user := User{Name: "user001", Age: 10, Role: "Admin", Addr: Address{Country: "CN", ZipCode: "001"}, Hobbys: []string{"a", "b"}, salary: 1000}
employee1 := Employee{}
CopyProperties(&employee1, &user)
employee1 := Employee{}
CopyProperties(&employee1, &user)
employee2 := Employee{Name: "employee001", Age: 20, Role: "User",
Addr: Address{Country: "UK", ZipCode: "002"}, salary: 500}
employee2 := Employee{Name: "employee001", Age: 20, Role: "User",
Addr: Address{Country: "UK", ZipCode: "002"}, salary: 500}
CopyProperties(&employee2, &user)
CopyProperties(&employee2, &user)
fmt.Println(employee1)
fmt.Println(employee2)
fmt.Println(employee1)
fmt.Println(employee2)
// Output:
// {user001 10 Admin {CN 001} [a b] 0}
// {user001 10 Admin {CN 001} [a b] 500}
// Output:
// {user001 10 Admin {CN 001} [a b] 0}
// {user001 10 Admin {CN 001} [a b] 500}
}
```

View File

@@ -652,45 +652,45 @@ import (
func main() {
type Struct struct {
Str string
Int int
Float float64
Bool bool
Nil interface{}
unexported string
}
Str string
Int int
Float float64
Bool bool
Nil interface{}
unexported string
}
cases := []interface{}{
true,
1,
0.1,
map[string]int{
"a": 1,
"b": 2,
},
&Struct{
Str: "test",
Int: 1,
Float: 0.1,
Bool: true,
Nil: nil,
// unexported: "can't be cloned",
},
}
cases := []interface{}{
true,
1,
0.1,
map[string]int{
"a": 1,
"b": 2,
},
&Struct{
Str: "test",
Int: 1,
Float: 0.1,
Bool: true,
Nil: nil,
// unexported: "can't be cloned",
},
}
for _, item := range cases {
cloned := convertor.DeepClone(item)
for _, item := range cases {
cloned := convertor.DeepClone(item)
isPointerEqual := &cloned == &item
fmt.Println(cloned, isPointerEqual)
}
isPointerEqual := &cloned == &item
fmt.Println(cloned, isPointerEqual)
}
// Output:
// true false
// 1 false
// 0.1 false
// map[a:1 b:2] false
// &{test 1 0.1 true <nil> } false
// Output:
// true false
// 1 false
// 0.1 false
// map[a:1 b:2] false
// &{test 1 0.1 true <nil> } false
}
```
@@ -716,43 +716,43 @@ import (
func main() {
type Address struct {
Country string
ZipCode string
}
Country string
ZipCode string
}
type User struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
type User struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
type Employee struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
type Employee struct {
Name string
Age int
Role string
Addr Address
Hobbys []string
salary int
}
user := User{Name: "user001", Age: 10, Role: "Admin", Addr: Address{Country: "CN", ZipCode: "001"}, Hobbys: []string{"a", "b"}, salary: 1000}
user := User{Name: "user001", Age: 10, Role: "Admin", Addr: Address{Country: "CN", ZipCode: "001"}, Hobbys: []string{"a", "b"}, salary: 1000}
employee1 := Employee{}
CopyProperties(&employee1, &user)
employee1 := Employee{}
CopyProperties(&employee1, &user)
employee2 := Employee{Name: "employee001", Age: 20, Role: "User",
Addr: Address{Country: "UK", ZipCode: "002"}, salary: 500}
employee2 := Employee{Name: "employee001", Age: 20, Role: "User",
Addr: Address{Country: "UK", ZipCode: "002"}, salary: 500}
CopyProperties(&employee2, &user)
CopyProperties(&employee2, &user)
fmt.Println(employee1)
fmt.Println(employee2)
fmt.Println(employee1)
fmt.Println(employee2)
// Output:
// {user001 10 Admin {CN 001} [a b] 0}
// {user001 10 Admin {CN 001} [a b] 500}
// Output:
// {user001 10 Admin {CN 001} [a b] 0}
// {user001 10 Admin {CN 001} [a b] 500}
}
```

View File

@@ -472,28 +472,28 @@ import (
func main() {
result1 := strutil.Pad("foo", 1, "bar")
result2 := strutil.Pad("foo", 2, "bar")
result3 := strutil.Pad("foo", 3, "bar")
result4 := strutil.Pad("foo", 4, "bar")
result5 := strutil.Pad("foo", 5, "bar")
result6 := strutil.Pad("foo", 6, "bar")
result7 := strutil.Pad("foo", 7, "bar")
result2 := strutil.Pad("foo", 2, "bar")
result3 := strutil.Pad("foo", 3, "bar")
result4 := strutil.Pad("foo", 4, "bar")
result5 := strutil.Pad("foo", 5, "bar")
result6 := strutil.Pad("foo", 6, "bar")
result7 := strutil.Pad("foo", 7, "bar")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result7)
// Output:
// foo
// foo
// foo
// foob
// bfoob
// bfooba
// bafooba
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result7)
// Output:
// foo
// foo
// foo
// foob
// bfoob
// bfooba
// bafooba
}
```
@@ -872,26 +872,26 @@ import (
func main() {
result1 := strutil.SplitWords("a word")
result2 := strutil.SplitWords("I'am a programmer")
result3 := strutil.SplitWords("Bonjour, je suis programmeur")
result4 := strutil.SplitWords("a -b-c' 'd'e")
result5 := strutil.SplitWords("你好,我是一名码农")
result6 := strutil.SplitWords("こんにちは,私はプログラマーです")
result2 := strutil.SplitWords("I'am a programmer")
result3 := strutil.SplitWords("Bonjour, je suis programmeur")
result4 := strutil.SplitWords("a -b-c' 'd'e")
result5 := strutil.SplitWords("你好,我是一名码农")
result6 := strutil.SplitWords("こんにちは,私はプログラマーです")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
// Output:
// [a word]
// [I'am a programmer]
// [Bonjour je suis programmeur]
// [a b-c' d'e]
// []
// []
// Output:
// [a word]
// [I'am a programmer]
// [Bonjour je suis programmeur]
// [a b-c' d'e]
// []
// []
}
```
@@ -916,25 +916,25 @@ import (
func main() {
result1 := strutil.WordCount("a word")
result2 := strutil.WordCount("I'am a programmer")
result3 := strutil.WordCount("Bonjour, je suis programmeur")
result4 := strutil.WordCount("a -b-c' 'd'e")
result5 := strutil.WordCount("你好,我是一名码农")
result6 := strutil.WordCount("こんにちは,私はプログラマーです")
result2 := strutil.WordCount("I'am a programmer")
result3 := strutil.WordCount("Bonjour, je suis programmeur")
result4 := strutil.WordCount("a -b-c' 'd'e")
result5 := strutil.WordCount("你好,我是一名码农")
result6 := strutil.WordCount("こんにちは,私はプログラマーです")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
// Output:
// 2
// 3
// 4
// 3
// 0
// 0
// Output:
// 2
// 3
// 4
// 3
// 0
// 0
}
```

View File

@@ -471,28 +471,28 @@ import (
func main() {
result1 := strutil.Pad("foo", 1, "bar")
result2 := strutil.Pad("foo", 2, "bar")
result3 := strutil.Pad("foo", 3, "bar")
result4 := strutil.Pad("foo", 4, "bar")
result5 := strutil.Pad("foo", 5, "bar")
result6 := strutil.Pad("foo", 6, "bar")
result7 := strutil.Pad("foo", 7, "bar")
result2 := strutil.Pad("foo", 2, "bar")
result3 := strutil.Pad("foo", 3, "bar")
result4 := strutil.Pad("foo", 4, "bar")
result5 := strutil.Pad("foo", 5, "bar")
result6 := strutil.Pad("foo", 6, "bar")
result7 := strutil.Pad("foo", 7, "bar")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result7)
// Output:
// foo
// foo
// foo
// foob
// bfoob
// bfooba
// bafooba
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result7)
// Output:
// foo
// foo
// foo
// foob
// bfoob
// bfooba
// bafooba
}
```
@@ -870,26 +870,26 @@ import (
func main() {
result1 := strutil.SplitWords("a word")
result2 := strutil.SplitWords("I'am a programmer")
result3 := strutil.SplitWords("Bonjour, je suis programmeur")
result4 := strutil.SplitWords("a -b-c' 'd'e")
result5 := strutil.SplitWords("你好,我是一名码农")
result6 := strutil.SplitWords("こんにちは,私はプログラマーです")
result2 := strutil.SplitWords("I'am a programmer")
result3 := strutil.SplitWords("Bonjour, je suis programmeur")
result4 := strutil.SplitWords("a -b-c' 'd'e")
result5 := strutil.SplitWords("你好,我是一名码农")
result6 := strutil.SplitWords("こんにちは,私はプログラマーです")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
// Output:
// [a word]
// [I'am a programmer]
// [Bonjour je suis programmeur]
// [a b-c' d'e]
// []
// []
// Output:
// [a word]
// [I'am a programmer]
// [Bonjour je suis programmeur]
// [a b-c' d'e]
// []
// []
}
```
@@ -914,25 +914,25 @@ import (
func main() {
result1 := strutil.WordCount("a word")
result2 := strutil.WordCount("I'am a programmer")
result3 := strutil.WordCount("Bonjour, je suis programmeur")
result4 := strutil.WordCount("a -b-c' 'd'e")
result5 := strutil.WordCount("你好,我是一名码农")
result6 := strutil.WordCount("こんにちは,私はプログラマーです")
result2 := strutil.WordCount("I'am a programmer")
result3 := strutil.WordCount("Bonjour, je suis programmeur")
result4 := strutil.WordCount("a -b-c' 'd'e")
result5 := strutil.WordCount("你好,我是一名码农")
result6 := strutil.WordCount("こんにちは,私はプログラマーです")
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
fmt.Println(result1)
fmt.Println(result2)
fmt.Println(result3)
fmt.Println(result4)
fmt.Println(result5)
fmt.Println(result6)
// Output:
// 2
// 3
// 4
// 3
// 0
// 0
// Output:
// 2
// 3
// 4
// 3
// 0
// 0
}
```