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

fix(log): toString float32 precision loss and convert uint use FormatUint #2461

Merged
merged 2 commits into from
Oct 19, 2022

Conversation

demoManito
Copy link
Member

@demoManito demoManito commented Oct 18, 2022

Description (what this PR does / why we need it):

  • float32
    Convert string precision loss

    switch v := v.(type) {
      case float32:
    -  key = strconv.FormatFloat(float64(v), 'f', -1, 64) 
    +  key = strconv.FormatFloat(float64(v), 'f', -1, 32) 
  • uint
    Convert uint with Itoa, will be treated as a signed int conversion,MaxUint will be converted to - 1, the correct return should be 18446744073709551615

Which issue(s) this PR fixes (resolves / be part of):

Other special notes for the reviewers:

@codecov-commenter
Copy link

Codecov Report

Merging #2461 (f34d4d7) into main (54655e4) will increase coverage by 0.00%.
The diff coverage is 100.00%.

❗ Current head f34d4d7 differs from pull request most recent head 8d3e397. Consider uploading reports for the commit 8d3e397 to get more accurate results

@@           Coverage Diff           @@
##             main    #2461   +/-   ##
=======================================
  Coverage   84.80%   84.81%           
=======================================
  Files          88       88           
  Lines        3797     3799    +2     
=======================================
+ Hits         3220     3222    +2     
  Misses        407      407           
  Partials      170      170           
Impacted Files Coverage Δ
log/level.go 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@demoManito demoManito changed the title fix(log): toString float32 precision loss fix(log): toString float32 precision loss and convert uint use FormatUint Oct 18, 2022
@tonybase tonybase merged commit a911f8f into go-kratos:main Oct 19, 2022
@demoManito demoManito deleted the fix/float32-precision-loss branch October 19, 2022 10:34
xiongpan828 pushed a commit to xiongpan828/kratos that referenced this pull request Jan 5, 2023
…tUint` (go-kratos#2461)

* fix(log): toString float32 precision loss

* convert uint to string
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.

None yet

3 participants