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

doc: format code in doc file

This commit is contained in:
dudaodong
2023-06-13 15:08:40 +08:00
parent 1e5b69e9bf
commit 69a797f8ed
8 changed files with 81 additions and 81 deletions

View File

@@ -608,16 +608,16 @@ import (
func main() { func main() {
val := reflect.ValueOf("abc") val := reflect.ValueOf("abc")
iVal, ok := convertor.ToInterface(val) iVal, ok := convertor.ToInterface(val)
fmt.Printf("%T\n", iVal) fmt.Printf("%T\n", iVal)
fmt.Printf("%v\n", iVal) fmt.Printf("%v\n", iVal)
fmt.Println(ok) fmt.Println(ok)
// Output: // Output:
// string // string
// abc // abc
// true // true
} }
``` ```

View File

@@ -608,16 +608,16 @@ import (
func main() { func main() {
val := reflect.ValueOf("abc") val := reflect.ValueOf("abc")
iVal, ok := convertor.ToInterface(val) iVal, ok := convertor.ToInterface(val)
fmt.Printf("%T\n", iVal) fmt.Printf("%T\n", iVal)
fmt.Printf("%v\n", iVal) fmt.Printf("%v\n", iVal)
fmt.Println(ok) fmt.Println(ok)
// Output: // Output:
// string // string
// abc // abc
// true // true
} }
``` ```

View File

@@ -199,18 +199,18 @@ import (
func main() { func main() {
now := time.Now() now := time.Now()
after1Year := datetime.AddYear(now, 1) after1Year := datetime.AddYear(now, 1)
diff1 := after1Year.Sub(now) diff1 := after1Year.Sub(now)
before1Year := datetime.AddYear(now, -1) before1Year := datetime.AddYear(now, -1)
diff2 := before1Year.Sub(now) diff2 := before1Year.Sub(now)
fmt.Println(diff1) fmt.Println(diff1)
fmt.Println(diff2) fmt.Println(diff2)
// Output: // Output:
// 8760h0m0s // 8760h0m0s
// -8760h0m0s // -8760h0m0s
} }
``` ```

View File

@@ -200,18 +200,18 @@ import (
func main() { func main() {
now := time.Now() now := time.Now()
after1Year := datetime.AddYear(now, 1) after1Year := datetime.AddYear(now, 1)
diff1 := after1Year.Sub(now) diff1 := after1Year.Sub(now)
before1Year := datetime.AddYear(now, -1) before1Year := datetime.AddYear(now, -1)
diff2 := before1Year.Sub(now) diff2 := before1Year.Sub(now)
fmt.Println(diff1) fmt.Println(diff1)
fmt.Println(diff2) fmt.Println(diff2)
// Output: // Output:
// 8760h0m0s // 8760h0m0s
// -8760h0m0s // -8760h0m0s
} }
``` ```

View File

@@ -323,16 +323,16 @@ import (
func main() { func main() {
addOne := func(x interface{}) interface{} { addOne := func(x interface{}) interface{} {
return x.(int) + 1 return x.(int) + 1
} }
double := func(x interface{}) interface{} { double := func(x interface{}) interface{} {
return 2 * x.(int) return 2 * x.(int)
} }
square := func(x interface{}) interface{} { square := func(x interface{}) interface{} {
return x.(int) * x.(int) return x.(int) * x.(int)
} }
f := function.Pipeline(addOne, double, square) f := function.Pipeline(addOne, double, square)
result := fn(2) result := fn(2)

View File

@@ -322,16 +322,16 @@ import (
func main() { func main() {
addOne := func(x interface{}) interface{} { addOne := func(x interface{}) interface{} {
return x.(int) + 1 return x.(int) + 1
} }
double := func(x interface{}) interface{} { double := func(x interface{}) interface{} {
return 2 * x.(int) return 2 * x.(int)
} }
square := func(x interface{}) interface{} { square := func(x interface{}) interface{} {
return x.(int) * x.(int) return x.(int) * x.(int)
} }
f := function.Pipeline(addOne, double, square) f := function.Pipeline(addOne, double, square)
result := fn(2) result := fn(2)

View File

@@ -658,24 +658,24 @@ import (
func main() { func main() {
url := "https://jsonplaceholder.typicode.com/todos" url := "https://jsonplaceholder.typicode.com/todos"
header := map[string]string{ header := map[string]string{
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
// "Content-Type": "multipart/form-data", // "Content-Type": "multipart/form-data",
} }
postData := url.Values{} postData := url.Values{}
postData.Add("userId", "1") postData.Add("userId", "1")
postData.Add("title", "TestToDo") postData.Add("title", "TestToDo")
// postData := make(map[string]string) // postData := make(map[string]string)
// postData["userId"] = "1" // postData["userId"] = "1"
// postData["title"] = "title" // postData["title"] = "title"
resp, err := netutil.HttpPost(apiUrl, header, nil, postData) resp, err := netutil.HttpPost(apiUrl, header, nil, postData)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
t.Log("response: ", resp.StatusCode, string(body)) t.Log("response: ", resp.StatusCode, string(body))
} }
``` ```

View File

@@ -657,23 +657,23 @@ import (
func main() { func main() {
url := "https://jsonplaceholder.typicode.com/todos" url := "https://jsonplaceholder.typicode.com/todos"
header := map[string]string{ header := map[string]string{
"Content-Type": "application/x-www-form-urlencoded", "Content-Type": "application/x-www-form-urlencoded",
// "Content-Type": "multipart/form-data", // "Content-Type": "multipart/form-data",
} }
postData := url.Values{} postData := url.Values{}
postData.Add("userId", "1") postData.Add("userId", "1")
postData.Add("title", "TestToDo") postData.Add("title", "TestToDo")
// postData := make(map[string]string) // postData := make(map[string]string)
// postData["userId"] = "1" // postData["userId"] = "1"
// postData["title"] = "title" // postData["title"] = "title"
resp, err := netutil.HttpPost(apiUrl, header, nil, postData) resp, err := netutil.HttpPost(apiUrl, header, nil, postData)
if err != nil { if err != nil {
log.Fatal(err) log.Fatal(err)
} }
body, _ := io.ReadAll(resp.Body) body, _ := io.ReadAll(resp.Body)
fmt.Println(body) fmt.Println(body)
} }
``` ```