Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

HugoWw
Copy link
Contributor

@HugoWw HugoWw commented Dec 1, 2023

支持map类型解析

Copy link

codecov bot commented Dec 4, 2023

Codecov Report

Attention: 22 lines in your changes are missing coverage. Please review.

Comparison is base (958a34b) 90.70% compared to head (4ccb43c) 89.46%.

Files Patch % Lines
reflect.go 80.86% 19 Missing and 3 partials ⚠️
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     
Flag Coverage Δ
all 89.46% <80.86%> (-1.25%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

func TestDefineWithNewType(t *testing.T) {
v := define(PetCat{})
b, _ := json.Marshal(v)
fmt.Printf("result:%v\n", string(b))
Copy link
Owner

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 {
Copy link
Owner

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.

Comment on lines +227 to +231
schemaMap := map[string]string{
"time.Time": "string",
"time.Duration": "integer",
"json.Number": "number",
}
Copy link
Owner

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.

@HugoWw
Copy link
Contributor Author

HugoWw commented Dec 4, 2023

map解析存在多2层以上嵌套问题,暂时不做pr

@HugoWw HugoWw closed this Dec 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants