summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaleb Bassi <calebjbassi@gmail.com>2018-02-19 20:00:18 -0800
committerCaleb Bassi <calebjbassi@gmail.com>2018-02-19 20:00:18 -0800
commit26942f61ae5aa8da74ab481f8655e098133affa9 (patch)
tree188c55d24fcab0bb473bcf2ae14ca047a8955a13
parentb26c871e283dfebce94e485959f30a11ea5b1788 (diff)
Changed large ints to uint64 for 32bit architectures1.0.1
-rw-r--r--README.md2
-rw-r--r--utils/utils.go12
-rw-r--r--widgets/disk.go2
-rw-r--r--widgets/net.go22
4 files changed, 20 insertions, 18 deletions
diff --git a/README.md b/README.md
index eda196c..48678fb 100644
--- a/README.md
+++ b/README.md
@@ -24,6 +24,8 @@ To uninstall:
sudo rm /usr/bin/gotop
```
+Currently only tested on Arch Linux x86_64, so create an issue if the binary for you OS doesn't work or if there isn't one.
+
### Arch Linux
diff --git a/utils/utils.go b/utils/utils.go
index 684a87b..9afd7d7 100644
--- a/utils/utils.go
+++ b/utils/utils.go
@@ -4,14 +4,14 @@ import (
"math"
)
-func BytesToKB(b int) int {
- return int((float64(b) / math.Pow10(3)))
+func BytesToKB(b uint64) uint64 {
+ return uint64((float64(b) / math.Pow10(3)))
}
-func BytesToMB(b int) int {
- return int((float64(b) / math.Pow10(6)))
+func BytesToMB(b uint64) uint64 {
+ return uint64((float64(b) / math.Pow10(6)))
}
-func BytesToGB(b int) int {
- return int((float64(b) / math.Pow10(9)))
+func BytesToGB(b uint64) uint64 {
+ return uint64((float64(b) / math.Pow10(9)))
}
diff --git a/widgets/disk.go b/widgets/disk.go
index 7b3c2c8..ee8581c 100644
--- a/widgets/disk.go
+++ b/widgets/disk.go
@@ -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(int(disk.Free)))
+ d.Description = fmt.Sprintf(" (%dGB free)", utils.BytesToGB(disk.Free))
}
diff --git a/widgets/net.go b/widgets/net.go
index 4d7dee3..a38be1a 100644
--- a/widgets/net.go
+++ b/widgets/net.go
@@ -12,8 +12,8 @@ import (
type Net struct {
*ui.Sparklines
interval time.Duration
- recvTotal int
- sentTotal int
+ recvTotal uint64
+ sentTotal uint64
}
func NewNet() *Net {
@@ -40,15 +40,15 @@ func NewNet() *Net {
func (n *Net) update() {
interfaces, _ := ps.IOCounters(false)
- recv := int(interfaces[0].BytesRecv)
- sent := int(interfaces[0].BytesSent)
+ recv := interfaces[0].BytesRecv
+ sent := interfaces[0].BytesSent
if n.recvTotal != 0 { // if this isn't the first update
curRecv := recv - n.recvTotal
curSent := sent - n.sentTotal
- n.Lines[0].Data = append(n.Lines[0].Data, curRecv)
- n.Lines[1].Data = append(n.Lines[1].Data, curSent)
+ n.Lines[0].Data = append(n.Lines[0].Data, int(curRecv))
+ n.Lines[1].Data = append(n.Lines[1].Data, int(curSent))
}
n.recvTotal = recv
@@ -56,7 +56,7 @@ func (n *Net) update() {
for i := 0; i < 2; i++ {
var method string
- var total int
+ var total uint64
cur := n.Lines[i].Data[len(n.Lines[i].Data)-1]
totalUnit := "B"
curUnit := "B"
@@ -70,18 +70,18 @@ func (n *Net) update() {
}
if cur >= 1000000 {
- cur = int(utils.BytesToMB(cur))
+ cur = int(utils.BytesToMB(uint64(cur)))
curUnit = "MB"
} else if cur >= 1000 {
- cur = int(utils.BytesToKB(cur))
+ cur = int(utils.BytesToKB(uint64(cur)))
curUnit = "kB"
}
if total >= 1000000000 {
- total = int(utils.BytesToGB(total))
+ total = utils.BytesToGB(total)
totalUnit = "GB"
} else if total >= 1000000 {
- total = int(utils.BytesToMB(total))
+ total = utils.BytesToMB(total)
totalUnit = "MB"
}