In some locales, the decimal separators is a comma
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 as 12,4. As a result, strconv.ParseFloat fails to parse floating-point numbers in the following lines of the getProcessList() function:
cpu, _ := strconv.ParseFloat(fields[2], 64)
mem, _ := strconv.ParseFloat(fields[3], 64)
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
Is there anything else that could cause this? I cloned your fork and I still see 0.00 in CPU and MEM usage.
LANG="fi_FI.UTF-8"
LC_COLLATE="fi_FI.UTF-8"
LC_CTYPE="fi_FI.UTF-8"
LC_MESSAGES="fi_FI.UTF-8"
LC_MONETARY="fi_FI.UTF-8"
LC_NUMERIC="fi_FI.UTF-8"
LC_TIME="fi_FI.UTF-8"
LC_ALL=
Here is my locale output
EDIT: sorry, I forgot to checkout to the dev branch before building. Your changes work on my end. M2 Pro 2023 Sequoia 15.0.0, finnish locale