-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat #36 support map kind #38
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #38 +/- ##
==========================================
- Coverage 90.70% 89.46% -1.25%
==========================================
Files 11 11
Lines 818 930 +112
==========================================
+ Hits 742 832 +90
- Misses 69 88 +19
- Partials 7 10 +3
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
func TestDefineWithNewType(t *testing.T) { | ||
v := define(PetCat{}) | ||
b, _ := json.Marshal(v) | ||
fmt.Printf("result:%v\n", string(b)) |
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.
Do not use fmt
output, instead use the correct expect and actual values for comparison.
// Example: | ||
// t ==> *[]*Struct|Struct|*string|string | ||
// p.GoType.Kind() ==> []*Struct|Struct|*string|string | ||
if p.GoType.Kind() == reflect.Slice { |
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.
Is it a repeated judgment?
The outer switch has determined Slice
.
schemaMap := map[string]string{ | ||
"time.Time": "string", | ||
"time.Duration": "integer", | ||
"json.Number": "number", | ||
} |
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.
It is recommended to put it in a global variable and reuse it.
map解析存在多2层以上嵌套问题,暂时不做pr |
支持map类型解析