gosigar icon indicating copy to clipboard operation
gosigar copied to clipboard

GetFileSystemUsage(...) returns Kilobytes instead of Bytes

Open lukaskirner opened this issue 2 years ago • 1 comments

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

lukaskirner avatar Nov 14 '23 15:11 lukaskirner

We would love to review a PR if you want to contribute.

beyhan avatar Nov 23 '23 16:11 beyhan