Remove human friendly digit group separators#141
Open
zleinweber wants to merge 1 commit into
Open
Conversation
Signed-off-by: Zach Leinweber <zach.leinweber@aquatic.com>
e392410 to
c55a252
Compare
SuperQ
reviewed
Jul 3, 2022
| pconfig "github.com/prometheus/common/config" | ||
| ) | ||
|
|
||
| var sanitzieValueRE = regexp.MustCompile(`(,|_)`) |
Contributor
There was a problem hiding this comment.
Rather than use a regexp, how about a string replacer?
Suggested change
| var sanitzieValueRE = regexp.MustCompile(`(,|_)`) | |
| var sanitzieValue = strings.NewReplacer(",", "", "|", "") |
Member
There was a problem hiding this comment.
- var sanitzieValue = strings.NewReplacer(",", "", "|", "")
+ var sanitzieValue = strings.NewReplacer(",", "", "_", "")| var resultErr string | ||
|
|
||
| if value, err = strconv.ParseFloat(s, 64); err == nil { | ||
| if value, err = strconv.ParseFloat(sanitzieValueRE.ReplaceAllString(s, ""), 64); err == nil { |
Contributor
There was a problem hiding this comment.
Suggested change
| if value, err = strconv.ParseFloat(sanitzieValueRE.ReplaceAllString(s, ""), 64); err == nil { | |
| if value, err = strconv.ParseFloat(sanitzieValue.Replace(s), 64); err == nil { |
SuperQ
requested changes
Jul 11, 2022
SuperQ
left a comment
Contributor
There was a problem hiding this comment.
Please use strings instead of regexp.
Contributor
|
Ping, please resolve requested changes. |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Some APIs that return numeric values as a string that include commas or underscores to separate digit groups. For example,
"1,000". This causes an error inSanitizeValuewhen the string gets passed intostrconv.ParseFloat().This fixes the problem above transparently.