Changed utils to return a float64
This commit is contained in:
parent
b262d2a547
commit
f0efec1ec7
@ -4,14 +4,14 @@ import (
|
||||
"math"
|
||||
)
|
||||
|
||||
func BytesToKB(b uint64) uint64 {
|
||||
return uint64((float64(b) / math.Pow10(3)))
|
||||
func BytesToKB(b uint64) float64 {
|
||||
return float64(b) / math.Pow10(3)
|
||||
}
|
||||
|
||||
func BytesToMB(b uint64) uint64 {
|
||||
return uint64((float64(b) / math.Pow10(6)))
|
||||
func BytesToMB(b uint64) float64 {
|
||||
return float64(b) / math.Pow10(6)
|
||||
}
|
||||
|
||||
func BytesToGB(b uint64) uint64 {
|
||||
return uint64((float64(b) / math.Pow10(9)))
|
||||
func BytesToGB(b uint64) float64 {
|
||||
return float64(b) / math.Pow10(9)
|
||||
}
|
||||
|
@ -33,5 +33,5 @@ func NewDisk() *Disk {
|
||||
func (d *Disk) update() {
|
||||
disk, _ := ps.Usage(d.fs)
|
||||
d.Percent = int(disk.UsedPercent)
|
||||
d.Description = fmt.Sprintf(" (%dGB free)", utils.BytesToGB(disk.Free))
|
||||
d.Description = fmt.Sprintf(" (%dGB free)", int(utils.BytesToGB(disk.Free)))
|
||||
}
|
||||
|
@ -77,15 +77,16 @@ func (n *Net) update() {
|
||||
curUnit = "kB"
|
||||
}
|
||||
|
||||
var totalCvrt float64
|
||||
if total >= 1000000000 {
|
||||
total = utils.BytesToGB(total)
|
||||
totalCvrt = utils.BytesToGB(total)
|
||||
totalUnit = "GB"
|
||||
} else if total >= 1000000 {
|
||||
total = utils.BytesToMB(total)
|
||||
totalCvrt = utils.BytesToMB(total)
|
||||
totalUnit = "MB"
|
||||
}
|
||||
|
||||
n.Lines[i].Title1 = fmt.Sprintf(" Total %s: %3d %s", method, total, totalUnit)
|
||||
n.Lines[i].Title2 = fmt.Sprintf(" %s/s: %7d %2s/s", method, cur, curUnit)
|
||||
n.Lines[i].Title1 = fmt.Sprintf(" Total %s: %5.1f %s", method, totalCvrt, totalUnit)
|
||||
n.Lines[i].Title2 = fmt.Sprintf(" %s/s: %9d %2s/s", method, cur, curUnit)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user