mirror of https://github.com/cjbassi/gotop.git
Fix process localization issues on FreeBSD
This commit is contained in:
parent
235c386a6c
commit
6907f598f8
|
@ -0,0 +1,13 @@
|
|||
package utils
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func ConvertLocalizedString(s string) string {
|
||||
if strings.ContainsAny(s, ",") {
|
||||
return strings.Replace(s, ",", ".", 1)
|
||||
} else {
|
||||
return s
|
||||
}
|
||||
}
|
|
@ -1,5 +1,3 @@
|
|||
// +build freebsd
|
||||
|
||||
package widgets
|
||||
|
||||
import (
|
||||
|
@ -9,6 +7,8 @@ import (
|
|||
"os/exec"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/cjbassi/gotop/src/utils"
|
||||
)
|
||||
|
||||
type processList struct {
|
||||
|
@ -44,11 +44,11 @@ func getProcs() ([]Proc, error) {
|
|||
if err != nil {
|
||||
log.Printf("failed to convert first field to int: %v. split: %v", err, process)
|
||||
}
|
||||
cpu, err := strconv.ParseFloat(process.Cpu, 64)
|
||||
cpu, err := strconv.ParseFloat(utils.ConvertLocalizedString(process.Cpu), 32)
|
||||
if err != nil {
|
||||
log.Printf("failed to convert third field to float: %v. split: %v", err, process)
|
||||
}
|
||||
mem, err := strconv.ParseFloat(process.Mem, 64)
|
||||
mem, err := strconv.ParseFloat(utils.ConvertLocalizedString(process.Mem), 32)
|
||||
if err != nil {
|
||||
log.Printf("failed to convert fourth field to float: %v. split: %v", err, process)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue