In some locales, the decimal separators is a comma #48
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.
It seems that the
ps
command respects locale settings and uses different decimal separators depending on the locale. For example, the Ukrainian (uk) locale uses a comma as the decimal separator instead of a period so CPU and MEM usage numbers are shown as12,4
. As a result,strconv.ParseFloat
fails to parse floating-point numbers in the following lines of the getProcessList() function:A more universal solution could involve checking the current locale, determining the decimal separator, or using a third-party module. However, in practice, there are only two common cases: a comma or a period. For this specific use case, simply replacing the comma with a period before parsing should be sufficient.
BTW
powermetrics -s tasks
didn't respect locale settings and used period as decimal separator.Fixes #47