-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support functions: Field/SliceInt/SliceInt64/SliceFloat64/SliceString
- Loading branch information
Showing
10 changed files
with
366 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
--- | ||
title: Others | ||
weight: 80 | ||
--- | ||
|
||
|
||
{{< toc >}} | ||
|
||
## Field | ||
Reference method `FieldE`. | ||
|
||
## FieldE | ||
Return the field value from map/struct, `interface{}`. | ||
|
||
```go | ||
// map | ||
cvt.FieldE(map[int]interface{}{123: "112233"}, "123") // "112233" | ||
cvt.FieldE(map[string]interface{}{"123": "112233"}, "123") // "112233" | ||
|
||
// struct | ||
cvt.FieldE(struct{ | ||
A string | ||
B int | ||
}{"Hello", 18}, "A") // "Hello" | ||
cvt.FieldE(struct{ | ||
A string | ||
B int | ||
}{"Hello", 18}, "B") // 18 | ||
``` | ||
|
||
|
||
> 更多示例请看单元测试:`cvte_test.go` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
--- | ||
title: 测试 | ||
weight: 20 | ||
--- | ||
|
||
## 命名约定 | ||
|
||
- `TestXXX_HasDefault`:测试带有默认值的方法 | ||
- `TestXXX_BaseLine`:测试没有带默认值的无错误方法 | ||
- `TestXXXE`:测试返回错误信息的方法 | ||
- `TestXXXP`:测试返回数据指针的方法 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
--- | ||
title: Others | ||
weight: 80 | ||
--- | ||
|
||
|
||
{{< toc >}} | ||
|
||
|
||
## Field | ||
参考 `FieldE` 方法。 | ||
|
||
## FieldE | ||
取 `map` 或 `struct` 的字段值,返回 `interface{}`。 | ||
|
||
```go | ||
// map | ||
cvt.FieldE(map[int]interface{}{123: "112233"}, "123") // "112233" | ||
cvt.FieldE(map[string]interface{}{"123": "112233"}, "123") // "112233" | ||
|
||
// struct | ||
cvt.FieldE(struct{ | ||
A string | ||
B int | ||
}{"Hello", 18}, "A") // "Hello" | ||
cvt.FieldE(struct{ | ||
A string | ||
B int | ||
}{"Hello", 18}, "B") // 18 | ||
``` | ||
|
||
|
||
> 更多示例请看单元测试:`cvte_test.go` | ||
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
21a699c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
cvt – ./
cvt-git-master-shockerli.vercel.app
cvt-shockerli.vercel.app
cvt-psi.vercel.app
cvt.shockerli.net