gosigar
gosigar copied to clipboard
GetFileSystemUsage(...) returns Kilobytes instead of Bytes
GetFileSystemUsage returns Kilobytes instead of Bytes.
Example Code which should print the used Gigabytes:
package main
import (
"fmt"
sigar "github.com/cloudfoundry/gosigar"
)
func main() {
s := sigar.ConcreteSigar{}
fsUsage, _ := s.GetFileSystemUsage("/System/Volumes/Data")
gbUsed := float64(fsUsage.Used) / 1024 / 1024 / 1024 // converting bytes to Gigabytes
fmt.Printf("%3.2f GB used\n", gbUsed)
}
Result on my machine:
0.34 GB used
Expected result:
> df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
...
/dev/disk3s5 460Gi 338Gi 108Gi 76% 6446774 1131120840 1% /System/Volumes/Data
...
OS: macOS gosigar version: 1.3.36
We would love to review a PR if you want to contribute.