cpu: fix command output trim problem.
This commit is contained in:
parent
8c17a750c6
commit
4bc631921f
|
@ -27,7 +27,7 @@ func init() {
|
||||||
out, err := exec.Command("/usr/bin/getconf", "CLK_TCK").Output()
|
out, err := exec.Command("/usr/bin/getconf", "CLK_TCK").Output()
|
||||||
// ignore errors
|
// ignore errors
|
||||||
if err == nil {
|
if err == nil {
|
||||||
i, err := strconv.ParseFloat(string(out), 64)
|
i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ClocksPerSec = float64(i)
|
ClocksPerSec = float64(i)
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func init() {
|
||||||
out, err := exec.Command("/usr/bin/getconf", "CLK_TCK").Output()
|
out, err := exec.Command("/usr/bin/getconf", "CLK_TCK").Output()
|
||||||
// ignore errors
|
// ignore errors
|
||||||
if err == nil {
|
if err == nil {
|
||||||
i, err := strconv.ParseFloat(string(out), 64)
|
i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
ClocksPerSec = float64(i)
|
ClocksPerSec = float64(i)
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@ func init() {
|
||||||
out, err := exec.Command("/usr/bin/getconf", "CLK_TCK").Output()
|
out, err := exec.Command("/usr/bin/getconf", "CLK_TCK").Output()
|
||||||
// ignore errors
|
// ignore errors
|
||||||
if err == nil {
|
if err == nil {
|
||||||
i, err := strconv.ParseFloat(string(out), 64)
|
i, err := strconv.ParseFloat(strings.TrimSpace(string(out)), 64)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
cpu_tick = float64(i)
|
cpu_tick = float64(i)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue